• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // DirItem.h
2 
3 #ifndef __DIR_ITEM_H
4 #define __DIR_ITEM_H
5 
6 #include "../../../Common/MyString.h"
7 
8 #include "../../../Windows/FileFind.h"
9 
10 #include "../../Common/UniqBlocks.h"
11 
12 #include "../../Archive/IArchive.h"
13 
14 struct CDirItemsStat
15 {
16   UInt64 NumDirs;
17   UInt64 NumFiles;
18   UInt64 NumAltStreams;
19   UInt64 FilesSize;
20   UInt64 AltStreamsSize;
21 
22   UInt64 NumErrors;
23   // UInt64 GetTotalItems() const { return NumDirs + NumFiles + NumAltStreams; }
24 
GetTotalBytesCDirItemsStat25   UInt64 GetTotalBytes() const { return FilesSize + AltStreamsSize; }
26 
CDirItemsStatCDirItemsStat27   CDirItemsStat():
28       NumDirs(0),
29       NumFiles(0),
30       NumAltStreams(0),
31       FilesSize(0),
32       AltStreamsSize(0),
33       NumErrors(0)
34     {}
35 };
36 
37 #define INTERFACE_IDirItemsCallback(x) \
38   virtual HRESULT ScanError(const FString &path, DWORD systemError) x; \
39   virtual HRESULT ScanProgress(const CDirItemsStat &st, const FString &path, bool isDir) x; \
40 
41 struct IDirItemsCallback
42 {
43   INTERFACE_IDirItemsCallback(=0)
44 };
45 
46 struct CDirItem
47 {
48   UInt64 Size;
49   FILETIME CTime;
50   FILETIME ATime;
51   FILETIME MTime;
52   UString Name;
53 
54   #if defined(_WIN32) && !defined(UNDER_CE)
55   // UString ShortName;
56   CByteBuffer ReparseData;
57   CByteBuffer ReparseData2; // fixed (reduced) absolute links
58 
AreReparseDataCDirItem59   bool AreReparseData() const { return ReparseData.Size() != 0 || ReparseData2.Size() != 0; }
60   #endif
61 
62   UInt32 Attrib;
63   int PhyParent;
64   int LogParent;
65   int SecureIndex;
66 
67   bool IsAltStream;
68 
CDirItemCDirItem69   CDirItem(): PhyParent(-1), LogParent(-1), SecureIndex(-1), IsAltStream(false) {}
IsDirCDirItem70   bool IsDir() const { return (Attrib & FILE_ATTRIBUTE_DIRECTORY) != 0 ; }
71 };
72 
73 class CDirItems
74 {
75   UStringVector Prefixes;
76   CIntVector PhyParents;
77   CIntVector LogParents;
78 
79   UString GetPrefixesPath(const CIntVector &parents, int index, const UString &name) const;
80 
81   HRESULT EnumerateDir(int phyParent, int logParent, const FString &phyPrefix);
82 
83 public:
84   CObjectVector<CDirItem> Items;
85 
86   bool SymLinks;
87 
88   bool ScanAltStreams;
89 
90   CDirItemsStat Stat;
91 
92   #ifndef UNDER_CE
93   HRESULT SetLinkInfo(CDirItem &dirItem, const NWindows::NFile::NFind::CFileInfo &fi,
94       const FString &phyPrefix);
95   #endif
96 
97 
98   #if defined(_WIN32) && !defined(UNDER_CE)
99 
100   CUniqBlocks SecureBlocks;
101   CByteBuffer TempSecureBuf;
102   bool _saclEnabled;
103   bool ReadSecure;
104 
105   HRESULT AddSecurityItem(const FString &path, int &secureIndex);
106 
107   #endif
108 
109   IDirItemsCallback *Callback;
110 
111   CDirItems();
112 
113   void AddDirFileInfo(int phyParent, int logParent, int secureIndex,
114       const NWindows::NFile::NFind::CFileInfo &fi);
115 
116   HRESULT AddError(const FString &path, DWORD errorCode);
117   HRESULT AddError(const FString &path);
118 
119   HRESULT ScanProgress(const FString &path);
120 
121   // unsigned GetNumFolders() const { return Prefixes.Size(); }
122   FString GetPhyPath(unsigned index) const;
123   UString GetLogPath(unsigned index) const;
124 
125   unsigned AddPrefix(int phyParent, int logParent, const UString &prefix);
126   void DeleteLastPrefix();
127 
128   HRESULT EnumerateItems2(
129     const FString &phyPrefix,
130     const UString &logPrefix,
131     const FStringVector &filePaths,
132     FStringVector *requestedPaths);
133 
134   #if defined(_WIN32) && !defined(UNDER_CE)
135   void FillFixedReparse();
136   #endif
137 
138   void ReserveDown();
139 };
140 
141 struct CArcItem
142 {
143   UInt64 Size;
144   FILETIME MTime;
145   UString Name;
146   bool IsDir;
147   bool IsAltStream;
148   bool SizeDefined;
149   bool MTimeDefined;
150   bool Censored;
151   UInt32 IndexInServer;
152   int TimeType;
153 
CArcItemCArcItem154   CArcItem(): IsDir(false), IsAltStream(false), SizeDefined(false), MTimeDefined(false), Censored(false), TimeType(-1) {}
155 };
156 
157 #endif
158