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 24 // UInt64 Get_NumItems() const { return NumDirs + NumFiles + NumAltStreams; } Get_NumDataItemsCDirItemsStat25 UInt64 Get_NumDataItems() const { return NumFiles + NumAltStreams; } GetTotalBytesCDirItemsStat26 UInt64 GetTotalBytes() const { return FilesSize + AltStreamsSize; } 27 IsEmptyCDirItemsStat28 bool IsEmpty() const { return 29 0 == NumDirs 30 && 0 == NumFiles 31 && 0 == NumAltStreams 32 && 0 == FilesSize 33 && 0 == AltStreamsSize 34 && 0 == NumErrors; } 35 CDirItemsStatCDirItemsStat36 CDirItemsStat(): 37 NumDirs(0), 38 NumFiles(0), 39 NumAltStreams(0), 40 FilesSize(0), 41 AltStreamsSize(0), 42 NumErrors(0) 43 {} 44 }; 45 46 47 struct CDirItemsStat2: public CDirItemsStat 48 { 49 UInt64 Anti_NumDirs; 50 UInt64 Anti_NumFiles; 51 UInt64 Anti_NumAltStreams; 52 53 // UInt64 Get_NumItems() const { return Anti_NumDirs + Anti_NumFiles + Anti_NumAltStreams + CDirItemsStat::Get_NumItems(); } Get_NumDataItems2CDirItemsStat254 UInt64 Get_NumDataItems2() const { return Anti_NumFiles + Anti_NumAltStreams + CDirItemsStat::Get_NumDataItems(); } 55 IsEmptyCDirItemsStat256 bool IsEmpty() const { return CDirItemsStat::IsEmpty() 57 && 0 == Anti_NumDirs 58 && 0 == Anti_NumFiles 59 && 0 == Anti_NumAltStreams; } 60 CDirItemsStat2CDirItemsStat261 CDirItemsStat2(): 62 Anti_NumDirs(0), 63 Anti_NumFiles(0), 64 Anti_NumAltStreams(0) 65 {} 66 }; 67 68 69 70 #define INTERFACE_IDirItemsCallback(x) \ 71 virtual HRESULT ScanError(const FString &path, DWORD systemError) x; \ 72 virtual HRESULT ScanProgress(const CDirItemsStat &st, const FString &path, bool isDir) x; \ 73 74 struct IDirItemsCallback 75 { 76 INTERFACE_IDirItemsCallback(=0) 77 }; 78 79 struct CDirItem 80 { 81 UInt64 Size; 82 FILETIME CTime; 83 FILETIME ATime; 84 FILETIME MTime; 85 UString Name; 86 87 #if defined(_WIN32) && !defined(UNDER_CE) 88 // UString ShortName; 89 CByteBuffer ReparseData; 90 CByteBuffer ReparseData2; // fixed (reduced) absolute links 91 AreReparseDataCDirItem92 bool AreReparseData() const { return ReparseData.Size() != 0 || ReparseData2.Size() != 0; } 93 #endif 94 95 UInt32 Attrib; 96 int PhyParent; 97 int LogParent; 98 int SecureIndex; 99 100 bool IsAltStream; 101 CDirItemCDirItem102 CDirItem(): PhyParent(-1), LogParent(-1), SecureIndex(-1), IsAltStream(false) {} IsDirCDirItem103 bool IsDir() const { return (Attrib & FILE_ATTRIBUTE_DIRECTORY) != 0 ; } 104 }; 105 106 class CDirItems 107 { 108 UStringVector Prefixes; 109 CIntVector PhyParents; 110 CIntVector LogParents; 111 112 UString GetPrefixesPath(const CIntVector &parents, int index, const UString &name) const; 113 114 HRESULT EnumerateDir(int phyParent, int logParent, const FString &phyPrefix); 115 116 public: 117 CObjectVector<CDirItem> Items; 118 119 bool SymLinks; 120 121 bool ScanAltStreams; 122 123 CDirItemsStat Stat; 124 125 #ifndef UNDER_CE 126 HRESULT SetLinkInfo(CDirItem &dirItem, const NWindows::NFile::NFind::CFileInfo &fi, 127 const FString &phyPrefix); 128 #endif 129 130 131 #if defined(_WIN32) && !defined(UNDER_CE) 132 133 CUniqBlocks SecureBlocks; 134 CByteBuffer TempSecureBuf; 135 bool _saclEnabled; 136 bool ReadSecure; 137 138 HRESULT AddSecurityItem(const FString &path, int &secureIndex); 139 140 #endif 141 142 IDirItemsCallback *Callback; 143 144 CDirItems(); 145 146 void AddDirFileInfo(int phyParent, int logParent, int secureIndex, 147 const NWindows::NFile::NFind::CFileInfo &fi); 148 149 HRESULT AddError(const FString &path, DWORD errorCode); 150 HRESULT AddError(const FString &path); 151 152 HRESULT ScanProgress(const FString &path); 153 154 // unsigned GetNumFolders() const { return Prefixes.Size(); } 155 FString GetPhyPath(unsigned index) const; 156 UString GetLogPath(unsigned index) const; 157 158 unsigned AddPrefix(int phyParent, int logParent, const UString &prefix); 159 void DeleteLastPrefix(); 160 161 HRESULT EnumerateItems2( 162 const FString &phyPrefix, 163 const UString &logPrefix, 164 const FStringVector &filePaths, 165 FStringVector *requestedPaths); 166 167 #if defined(_WIN32) && !defined(UNDER_CE) 168 void FillFixedReparse(); 169 #endif 170 171 void ReserveDown(); 172 }; 173 174 struct CArcItem 175 { 176 UInt64 Size; 177 FILETIME MTime; 178 UString Name; 179 bool IsDir; 180 bool IsAltStream; 181 bool SizeDefined; 182 bool MTimeDefined; 183 bool Censored; 184 UInt32 IndexInServer; 185 int TimeType; 186 CArcItemCArcItem187 CArcItem(): IsDir(false), IsAltStream(false), SizeDefined(false), MTimeDefined(false), Censored(false), TimeType(-1) {} 188 }; 189 190 #endif 191