• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 bool IsDrivePath(const wchar_t *s) throw();  // first 3 chars are drive chars like "a:\\"
21 
22 bool IsAltPathPrefix(CFSTR s) throw(); /* name: */
23 
24 #if defined(_WIN32) && !defined(UNDER_CE)
25 
26 extern const char * const kSuperPathPrefix; /* \\?\ */
27 const unsigned kDevicePathPrefixSize = 4;
28 const unsigned kSuperPathPrefixSize = 4;
29 const unsigned kSuperUncPathPrefixSize = kSuperPathPrefixSize + 4;
30 
31 bool IsDevicePath(CFSTR s) throw();   /* \\.\ */
32 bool IsSuperUncPath(CFSTR s) throw(); /* \\?\UNC\ */
33 bool IsNetworkPath(CFSTR s) throw();  /* \\?\UNC\ or \\SERVER */
34 
35 /* GetNetworkServerPrefixSize() returns size of server prefix:
36      \\?\UNC\SERVER\
37      \\SERVER\
38   in another cases it returns 0
39 */
40 
41 unsigned GetNetworkServerPrefixSize(CFSTR s) throw();
42 
43 bool IsNetworkShareRootPath(CFSTR s) throw();  /* \\?\UNC\SERVER\share or \\SERVER\share or with slash */
44 
45 bool IsDrivePath_SuperAllowed(CFSTR s) throw();  // first chars are drive chars like "a:\" or "\\?\a:\"
46 bool IsDriveRootPath_SuperAllowed(CFSTR s) throw();  // exact drive root path "a:\" or "\\?\a:\"
47 
48 bool IsDrivePath2(const wchar_t *s) throw(); // first 2 chars are drive chars like "a:"
49 // bool IsDriveName2(const wchar_t *s) throw(); // is drive name like "a:"
50 bool IsSuperPath(const wchar_t *s) throw();
51 bool IsSuperOrDevicePath(const wchar_t *s) throw();
52 
53 #ifndef USE_UNICODE_FSTRING
54 bool IsDrivePath2(CFSTR s) throw(); // first 2 chars are drive chars like "a:"
55 // bool IsDriveName2(CFSTR s) throw(); // is drive name like "a:"
56 bool IsDrivePath(CFSTR s) throw();
57 bool IsSuperPath(CFSTR s) throw();
58 bool IsSuperOrDevicePath(CFSTR s) throw();
59 
60 /* GetRootPrefixSize() returns size of ROOT PREFIX for cases:
61      \
62      \\.\
63      C:\
64      \\?\C:\
65      \\?\UNC\SERVER\Shared\
66      \\SERVER\Shared\
67   in another cases it returns 0
68 */
69 
70 unsigned GetRootPrefixSize(CFSTR s) throw();
71 
72 #endif
73 
74 int FindAltStreamColon(CFSTR path) throw();
75 
76 #endif // _WIN32
77 
78 bool IsAbsolutePath(const wchar_t *s) throw();
79 unsigned GetRootPrefixSize(const wchar_t *s) throw();
80 
81 #ifdef WIN_LONG_PATH
82 
83 const int kSuperPathType_UseOnlyMain = 0;
84 const int kSuperPathType_UseOnlySuper = 1;
85 const int kSuperPathType_UseMainAndSuper = 2;
86 
87 int GetUseSuperPathType(CFSTR s) throw();
88 bool GetSuperPath(CFSTR path, UString &superPath, bool onlyIfNew);
89 bool GetSuperPaths(CFSTR s1, CFSTR s2, UString &d1, UString &d2, bool onlyIfNew);
90 
91 #define USE_MAIN_PATH (__useSuperPathType != kSuperPathType_UseOnlySuper)
92 #define USE_MAIN_PATH_2 (__useSuperPathType1 != kSuperPathType_UseOnlySuper && __useSuperPathType2 != kSuperPathType_UseOnlySuper)
93 
94 #define USE_SUPER_PATH (__useSuperPathType != kSuperPathType_UseOnlyMain)
95 #define USE_SUPER_PATH_2 (__useSuperPathType1 != kSuperPathType_UseOnlyMain || __useSuperPathType2 != kSuperPathType_UseOnlyMain)
96 
97 #define IF_USE_MAIN_PATH int __useSuperPathType = GetUseSuperPathType(path); if (USE_MAIN_PATH)
98 #define IF_USE_MAIN_PATH_2(x1, x2) \
99     int __useSuperPathType1 = GetUseSuperPathType(x1); \
100     int __useSuperPathType2 = GetUseSuperPathType(x2); \
101     if (USE_MAIN_PATH_2)
102 
103 #else
104 
105 #define IF_USE_MAIN_PATH
106 #define IF_USE_MAIN_PATH_2(x1, x2)
107 
108 #endif // WIN_LONG_PATH
109 
110 bool GetFullPath(CFSTR dirPrefix, CFSTR path, FString &fullPath);
111 bool GetFullPath(CFSTR path, FString &fullPath);
112 
113 }}}
114 
115 #endif
116