1 // Windows/FileDir.h 2 3 #ifndef __WINDOWS_FILE_DIR_H 4 #define __WINDOWS_FILE_DIR_H 5 6 #include "../Common/MyString.h" 7 #include "FileIO.h" 8 9 namespace NWindows { 10 namespace NFile { 11 namespace NDirectory { 12 13 #ifdef WIN_LONG_PATH 14 bool GetLongPaths(CFSTR s1, CFSTR s2, UString &d1, UString &d2); 15 #endif 16 17 bool MyGetWindowsDirectory(FString &path); 18 bool MyGetSystemDirectory(FString &path); 19 20 bool SetDirTime(CFSTR fileName, const FILETIME *cTime, const FILETIME *aTime, const FILETIME *mTime); 21 bool MySetFileAttributes(CFSTR fileName, DWORD fileAttributes); 22 bool MyMoveFile(CFSTR existFileName, CFSTR newFileName); 23 bool MyRemoveDirectory(CFSTR path); 24 bool MyCreateDirectory(CFSTR path); 25 bool CreateComplexDirectory(CFSTR path); 26 bool DeleteFileAlways(CFSTR name); 27 bool RemoveDirectoryWithSubItems(const FString &path); 28 29 bool MyGetFullPathName(CFSTR path, FString &resFullPath); 30 bool GetFullPathAndSplit(CFSTR path, FString &resDirPrefix, FString &resFileName); 31 bool GetOnlyDirPrefix(CFSTR path, FString &resDirPrefix); 32 33 #ifndef UNDER_CE 34 35 bool MySetCurrentDirectory(CFSTR path); 36 bool MyGetCurrentDirectory(FString &resultPath); 37 38 #endif 39 40 bool MyGetTempPath(FString &resultPath); 41 42 class CTempFile 43 { 44 bool _mustBeDeleted; 45 FString _path; DisableDeleting()46 void DisableDeleting() { _mustBeDeleted = false; } 47 public: CTempFile()48 CTempFile(): _mustBeDeleted(false) {} ~CTempFile()49 ~CTempFile() { Remove(); } GetPath()50 const FString &GetPath() const { return _path; } 51 bool Create(CFSTR pathPrefix, NIO::COutFile *outFile); // pathPrefix is not folder prefix 52 bool CreateRandomInTempFolder(CFSTR namePrefix, NIO::COutFile *outFile); 53 bool Remove(); 54 bool MoveTo(CFSTR name, bool deleteDestBefore); 55 }; 56 57 class CTempDir 58 { 59 bool _mustBeDeleted; 60 FString _path; 61 public: CTempDir()62 CTempDir(): _mustBeDeleted(false) {} ~CTempDir()63 ~CTempDir() { Remove(); } GetPath()64 const FString &GetPath() const { return _path; } DisableDeleting()65 void DisableDeleting() { _mustBeDeleted = false; } 66 bool Create(CFSTR namePrefix) ; 67 bool Remove(); 68 }; 69 70 }}} 71 72 #endif 73