1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
// FSFolder.h
#ifndef __FS_FOLDER_H
#define __FS_FOLDER_H
#include "Common/MyCom.h"
#include "Windows/FileFind.h"
#include "IFolder.h"
#include "TextPairs.h"
namespace NFsFolder {
class CFSFolder;
struct CFileInfoEx: public NWindows::NFile::NFind::CFileInfo
{
#ifndef UNDER_CE
bool CompressedSizeIsDefined;
UInt64 CompressedSize;
#endif
};
struct CDirItem;
struct CDirItem: public CFileInfoEx
{
CDirItem *Parent;
CObjectVector<CDirItem> Files;
CDirItem(): Parent(0) {}
void Clear()
{
Files.Clear();
Parent = 0;
}
};
class CFSFolder:
public IFolderFolder,
public IFolderWasChanged,
public IFolderOperations,
// public IFolderOperationsDeleteToRecycleBin,
public IFolderGetItemFullSize,
public IFolderClone,
public IFolderGetSystemIconIndex,
public IFolderSetFlatMode,
public CMyUnknownImp
{
UInt64 GetSizeOfItem(int anIndex) const;
public:
MY_QUERYINTERFACE_BEGIN2(IFolderFolder)
MY_QUERYINTERFACE_ENTRY(IFolderWasChanged)
// MY_QUERYINTERFACE_ENTRY(IFolderOperationsDeleteToRecycleBin)
MY_QUERYINTERFACE_ENTRY(IFolderOperations)
MY_QUERYINTERFACE_ENTRY(IFolderGetItemFullSize)
MY_QUERYINTERFACE_ENTRY(IFolderClone)
MY_QUERYINTERFACE_ENTRY(IFolderGetSystemIconIndex)
MY_QUERYINTERFACE_ENTRY(IFolderSetFlatMode)
MY_QUERYINTERFACE_END
MY_ADDREF_RELEASE
INTERFACE_FolderFolder(;)
INTERFACE_FolderOperations(;)
STDMETHOD(WasChanged)(Int32 *wasChanged);
STDMETHOD(Clone)(IFolderFolder **resultFolder);
STDMETHOD(GetItemFullSize)(UInt32 index, PROPVARIANT *value, IProgress *progress);
STDMETHOD(SetFlatMode)(Int32 flatMode);
STDMETHOD(GetSystemIconIndex)(UInt32 index, Int32 *iconIndex);
private:
FString _path;
CDirItem _root;
CRecordVector<CDirItem *> _refs;
CMyComPtr<IFolderFolder> _parentFolder;
bool _commentsAreLoaded;
CPairsStorage _comments;
bool _flatMode;
NWindows::NFile::NFind::CFindChangeNotification _findChangeNotification;
HRESULT GetItemsFullSize(const UInt32 *indices, UInt32 numItems,
UInt64 &numFolders, UInt64 &numFiles, UInt64 &size, IProgress *progress);
HRESULT GetItemFullSize(int index, UInt64 &size, IProgress *progress);
HRESULT GetComplexName(CFSTR name, FString &resultPath);
HRESULT BindToFolderSpec(CFSTR name, IFolderFolder **resultFolder);
bool LoadComments();
bool SaveComments();
HRESULT LoadSubItems(CDirItem &dirItem, const FString &path);
void AddRefs(CDirItem &dirItem);
public:
HRESULT Init(const FString &path, IFolderFolder *parentFolder);
#ifdef UNDER_CE
HRESULT InitToRoot() { return Init(FTEXT("\\"), NULL); }
#endif
CFSFolder() : _flatMode(false) {}
FString GetPrefix(const CDirItem &item) const;
FString GetRelPath(const CDirItem &item) const;
FString GetRelPath(UInt32 index) const { return GetRelPath(*_refs[index]); }
void Clear()
{
_root.Clear();
_refs.Clear();
}
};
}
#endif
|