1 // FSFolder.h 2 3 #ifndef ZIP7_INC_FS_FOLDER_H 4 #define ZIP7_INC_FS_FOLDER_H 5 6 #include "../../../Common/MyCom.h" 7 #include "../../../Common/MyBuffer.h" 8 9 #include "../../../Windows/FileFind.h" 10 11 #include "../../Archive/IArchive.h" 12 13 #include "IFolder.h" 14 #include "TextPairs.h" 15 16 namespace NFsFolder { 17 18 class CFSFolder; 19 20 #define FS_SHOW_LINKS_INFO 21 // #define FS_SHOW_CHANGE_TIME 22 23 struct CDirItem: public NWindows::NFile::NFind::CFileInfo 24 { 25 #ifndef UNDER_CE 26 UInt64 PackSize; 27 #endif 28 29 #ifdef FS_SHOW_LINKS_INFO 30 FILETIME ChangeTime; 31 UInt64 FileIndex; 32 UInt32 NumLinks; 33 bool FileInfo_Defined; 34 bool FileInfo_WasRequested; 35 bool ChangeTime_Defined; 36 bool ChangeTime_WasRequested; 37 #endif 38 39 #ifndef UNDER_CE 40 bool PackSize_Defined; 41 #endif 42 43 bool FolderStat_Defined; 44 45 #ifndef UNDER_CE 46 CByteBuffer Reparse; 47 #endif 48 49 UInt64 NumFolders; 50 UInt64 NumFiles; 51 52 int Parent; 53 }; 54 55 /* 56 struct CAltStream 57 { 58 UInt64 Size; 59 UInt64 PackSize; 60 bool PackSize_Defined; 61 int Parent; 62 UString Name; 63 }; 64 */ 65 66 struct CFsFolderStat 67 { 68 UInt64 NumFolders; 69 UInt64 NumFiles; 70 UInt64 Size; 71 IProgress *Progress; 72 FString Path; 73 CFsFolderStatCFsFolderStat74 CFsFolderStat(): NumFolders(0), NumFiles(0), Size(0), Progress(NULL) {} 75 CFsFolderStat(const FString &path, IProgress *progress = NULL): 76 NumFolders(0), NumFiles(0), Size(0), Progress(progress), Path(path) {} 77 78 HRESULT Enumerate(); 79 }; 80 81 class CFSFolder Z7_final: 82 public IFolderFolder, 83 public IArchiveGetRawProps, 84 public IFolderCompare, 85 #ifdef USE_UNICODE_FSTRING 86 public IFolderGetItemName, 87 #endif 88 public IFolderWasChanged, 89 public IFolderOperations, 90 // public IFolderOperationsDeleteToRecycleBin, 91 public IFolderCalcItemFullSize, 92 public IFolderClone, 93 public IFolderGetSystemIconIndex, 94 public IFolderSetFlatMode, 95 // public IFolderSetShowNtfsStreamsMode, 96 public CMyUnknownImp 97 { 98 Z7_COM_QI_BEGIN2(IFolderFolder) 99 Z7_COM_QI_ENTRY(IArchiveGetRawProps) 100 Z7_COM_QI_ENTRY(IFolderCompare) 101 #ifdef USE_UNICODE_FSTRING 102 Z7_COM_QI_ENTRY(IFolderGetItemName) 103 #endif 104 Z7_COM_QI_ENTRY(IFolderWasChanged) 105 // Z7_COM_QI_ENTRY(IFolderOperationsDeleteToRecycleBin) 106 Z7_COM_QI_ENTRY(IFolderOperations) 107 Z7_COM_QI_ENTRY(IFolderCalcItemFullSize) 108 Z7_COM_QI_ENTRY(IFolderClone) 109 Z7_COM_QI_ENTRY(IFolderGetSystemIconIndex) 110 Z7_COM_QI_ENTRY(IFolderSetFlatMode) 111 // Z7_COM_QI_ENTRY(IFolderSetShowNtfsStreamsMode) 112 Z7_COM_QI_END 113 Z7_COM_ADDREF_RELEASE 114 115 Z7_IFACE_COM7_IMP(IFolderFolder) 116 Z7_IFACE_COM7_IMP(IArchiveGetRawProps) 117 Z7_IFACE_COM7_IMP(IFolderCompare) 118 #ifdef USE_UNICODE_FSTRING 119 Z7_IFACE_COM7_IMP(IFolderGetItemName) 120 #endif 121 Z7_IFACE_COM7_IMP(IFolderWasChanged) 122 Z7_IFACE_COM7_IMP(IFolderOperations) 123 Z7_IFACE_COM7_IMP(IFolderCalcItemFullSize) 124 Z7_IFACE_COM7_IMP(IFolderClone) 125 Z7_IFACE_COM7_IMP(IFolderGetSystemIconIndex) 126 Z7_IFACE_COM7_IMP(IFolderSetFlatMode) 127 // Z7_IFACE_COM7_IMP(IFolderSetShowNtfsStreamsMode) 128 129 private: 130 FString _path; 131 132 CObjectVector<CDirItem> Files; 133 FStringVector Folders; 134 // CObjectVector<CAltStream> Streams; 135 // CMyComPtr<IFolderFolder> _parentFolder; 136 137 bool _commentsAreLoaded; 138 CPairsStorage _comments; 139 140 // bool _scanAltStreams; 141 bool _flatMode; 142 143 #ifdef _WIN32 144 NWindows::NFile::NFind::CFindChangeNotification _findChangeNotification; 145 #endif 146 147 // HRESULT GetItemFullSize(unsigned index, UInt64 &size, IProgress *progress); 148 void GetAbsPath(const wchar_t *name, FString &absPath); 149 HRESULT BindToFolderSpec(CFSTR name, IFolderFolder **resultFolder); 150 151 bool LoadComments(); 152 bool SaveComments(); 153 HRESULT LoadSubItems(int dirItem, const FString &path); 154 155 #ifdef FS_SHOW_LINKS_INFO 156 bool ReadFileInfo(CDirItem &di); 157 void ReadChangeTime(CDirItem &di); 158 #endif 159 160 public: 161 HRESULT Init(const FString &path /* , IFolderFolder *parentFolder */); 162 #if !defined(_WIN32) || defined(UNDER_CE) InitToRoot()163 HRESULT InitToRoot() { return Init((FString) FSTRING_PATH_SEPARATOR /* , NULL */); } 164 #endif 165 CFSFolder()166 CFSFolder() : _flatMode(false) 167 // , _scanAltStreams(false) 168 {} 169 GetFullPath(const CDirItem & item,FString & path)170 void GetFullPath(const CDirItem &item, FString &path) const 171 { 172 // FString prefix; 173 // GetPrefix(item, prefix); 174 path = _path; 175 if (item.Parent >= 0) 176 path += Folders[item.Parent]; 177 path += item.Name; 178 } 179 180 // void GetPrefix(const CDirItem &item, FString &prefix) const; 181 182 FString GetRelPath(const CDirItem &item) const; 183 Clear()184 void Clear() 185 { 186 Files.Clear(); 187 Folders.Clear(); 188 // Streams.Clear(); 189 } 190 }; 191 192 struct CCopyStateIO 193 { 194 IProgress *Progress; 195 UInt64 TotalSize; 196 UInt64 StartPos; 197 UInt64 CurrentSize; 198 bool DeleteSrcFile; 199 200 int ErrorFileIndex; 201 UString ErrorMessage; 202 CCopyStateIOCCopyStateIO203 CCopyStateIO(): TotalSize(0), StartPos(0), DeleteSrcFile(false) {} 204 205 HRESULT MyCopyFile(CFSTR inPath, CFSTR outPath, DWORD attrib = INVALID_FILE_ATTRIBUTES); 206 }; 207 208 HRESULT SendLastErrorMessage(IFolderOperationsExtractCallback *callback, const FString &fileName); 209 210 /* destDirPrefix is allowed to be: 211 "full_path\" or "full_path:" for alt streams */ 212 213 HRESULT CopyFileSystemItems( 214 const UStringVector &itemsPaths, 215 const FString &destDirPrefix, 216 bool moveMode, 217 IFolderOperationsExtractCallback *callback); 218 219 } 220 221 #endif 222