1 // Windows/FileName.h 2 3 #ifndef __WINDOWS_FILE_NAME_H 4 #define __WINDOWS_FILE_NAME_H 5 6 #include "../Common/MyString.h" 7 8 namespace NWindows { 9 namespace NFile { 10 namespace NName { 11 12 int FindSepar(const wchar_t *s) throw(); 13 #ifndef USE_UNICODE_FSTRING 14 int FindSepar(const FChar *s) throw(); 15 #endif 16 17 void NormalizeDirPathPrefix(FString &dirPath); // ensures that it ended with '\\', if dirPath is not epmty 18 void NormalizeDirPathPrefix(UString &dirPath); 19 20 #ifdef _WIN32 21 void NormalizeDirSeparators(FString &s); 22 #endif 23 24 bool IsDrivePath(const wchar_t *s) throw(); // first 3 chars are drive chars like "a:\\" 25 26 bool IsAltPathPrefix(CFSTR s) throw(); /* name: */ 27 28 #if defined(_WIN32) && !defined(UNDER_CE) 29 30 extern const char * const kSuperPathPrefix; /* \\?\ */ 31 const unsigned kDevicePathPrefixSize = 4; 32 const unsigned kSuperPathPrefixSize = 4; 33 const unsigned kSuperUncPathPrefixSize = kSuperPathPrefixSize + 4; 34 35 bool IsDevicePath(CFSTR s) throw(); /* \\.\ */ 36 bool IsSuperUncPath(CFSTR s) throw(); /* \\?\UNC\ */ 37 bool IsNetworkPath(CFSTR s) throw(); /* \\?\UNC\ or \\SERVER */ 38 39 /* GetNetworkServerPrefixSize() returns size of server prefix: 40 \\?\UNC\SERVER\ 41 \\SERVER\ 42 in another cases it returns 0 43 */ 44 45 unsigned GetNetworkServerPrefixSize(CFSTR s) throw(); 46 47 bool IsNetworkShareRootPath(CFSTR s) throw(); /* \\?\UNC\SERVER\share or \\SERVER\share or with slash */ 48 49 bool IsDrivePath_SuperAllowed(CFSTR s) throw(); // first chars are drive chars like "a:\" or "\\?\a:\" 50 bool IsDriveRootPath_SuperAllowed(CFSTR s) throw(); // exact drive root path "a:\" or "\\?\a:\" 51 52 bool IsDrivePath2(const wchar_t *s) throw(); // first 2 chars are drive chars like "a:" 53 // bool IsDriveName2(const wchar_t *s) throw(); // is drive name like "a:" 54 bool IsSuperPath(const wchar_t *s) throw(); 55 bool IsSuperOrDevicePath(const wchar_t *s) throw(); 56 57 #ifndef USE_UNICODE_FSTRING 58 bool IsDrivePath2(CFSTR s) throw(); // first 2 chars are drive chars like "a:" 59 // bool IsDriveName2(CFSTR s) throw(); // is drive name like "a:" 60 bool IsDrivePath(CFSTR s) throw(); 61 bool IsSuperPath(CFSTR s) throw(); 62 bool IsSuperOrDevicePath(CFSTR s) throw(); 63 64 /* GetRootPrefixSize() returns size of ROOT PREFIX for cases: 65 \ 66 \\.\ 67 C:\ 68 \\?\C:\ 69 \\?\UNC\SERVER\Shared\ 70 \\SERVER\Shared\ 71 in another cases it returns 0 72 */ 73 74 unsigned GetRootPrefixSize(CFSTR s) throw(); 75 76 #endif 77 78 int FindAltStreamColon(CFSTR path) throw(); 79 80 #endif // _WIN32 81 82 bool IsAbsolutePath(const wchar_t *s) throw(); 83 unsigned GetRootPrefixSize(const wchar_t *s) throw(); 84 85 #ifdef WIN_LONG_PATH 86 87 const int kSuperPathType_UseOnlyMain = 0; 88 const int kSuperPathType_UseOnlySuper = 1; 89 const int kSuperPathType_UseMainAndSuper = 2; 90 91 int GetUseSuperPathType(CFSTR s) throw(); 92 bool GetSuperPath(CFSTR path, UString &superPath, bool onlyIfNew); 93 bool GetSuperPaths(CFSTR s1, CFSTR s2, UString &d1, UString &d2, bool onlyIfNew); 94 95 #define USE_MAIN_PATH (__useSuperPathType != kSuperPathType_UseOnlySuper) 96 #define USE_MAIN_PATH_2 (__useSuperPathType1 != kSuperPathType_UseOnlySuper && __useSuperPathType2 != kSuperPathType_UseOnlySuper) 97 98 #define USE_SUPER_PATH (__useSuperPathType != kSuperPathType_UseOnlyMain) 99 #define USE_SUPER_PATH_2 (__useSuperPathType1 != kSuperPathType_UseOnlyMain || __useSuperPathType2 != kSuperPathType_UseOnlyMain) 100 101 #define IF_USE_MAIN_PATH int __useSuperPathType = GetUseSuperPathType(path); if (USE_MAIN_PATH) 102 #define IF_USE_MAIN_PATH_2(x1, x2) \ 103 int __useSuperPathType1 = GetUseSuperPathType(x1); \ 104 int __useSuperPathType2 = GetUseSuperPathType(x2); \ 105 if (USE_MAIN_PATH_2) 106 107 #else 108 109 #define IF_USE_MAIN_PATH 110 #define IF_USE_MAIN_PATH_2(x1, x2) 111 112 #endif // WIN_LONG_PATH 113 114 bool GetFullPath(CFSTR dirPrefix, CFSTR path, FString &fullPath); 115 bool GetFullPath(CFSTR path, FString &fullPath); 116 117 }}} 118 119 #endif 120