• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Windows/FileName.h
2 
3 #ifndef ZIP7_INC_WINDOWS_FILE_NAME_H
4 #define ZIP7_INC_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 bool IsAltStreamPrefixWithColon(const UString &s) throw();
58 // returns true, if super prefix was removed
59 bool If_IsSuperPath_RemoveSuperPrefix(UString &s);
60 
61 #ifndef USE_UNICODE_FSTRING
62 bool IsDrivePath2(CFSTR s) throw(); // first 2 chars are drive chars like "a:"
63 // bool IsDriveName2(CFSTR s) throw(); // is drive name like "a:"
64 bool IsDrivePath(CFSTR s) throw();
65 bool IsSuperPath(CFSTR s) throw();
66 bool IsSuperOrDevicePath(CFSTR s) throw();
67 
68 /* GetRootPrefixSize() returns size of ROOT PREFIX for cases:
69      \
70      \\.\
71      C:\
72      \\?\C:\
73      \\?\UNC\SERVER\Shared\
74      \\SERVER\Shared\
75   in another cases it returns 0
76 */
77 
78 unsigned GetRootPrefixSize(CFSTR s) throw();
79 
80 #endif
81 
82 int FindAltStreamColon(CFSTR path) throw();
83 
84 #endif // _WIN32
85 
86 bool IsAbsolutePath(const wchar_t *s) throw();
87 unsigned GetRootPrefixSize(const wchar_t *s) throw();
88 
89 #ifdef Z7_LONG_PATH
90 
91 const int kSuperPathType_UseOnlyMain = 0;
92 const int kSuperPathType_UseOnlySuper = 1;
93 const int kSuperPathType_UseMainAndSuper = 2;
94 
95 int GetUseSuperPathType(CFSTR s) throw();
96 bool GetSuperPath(CFSTR path, UString &superPath, bool onlyIfNew);
97 bool GetSuperPaths(CFSTR s1, CFSTR s2, UString &d1, UString &d2, bool onlyIfNew);
98 
99 #define USE_MAIN_PATH (_useSuperPathType != kSuperPathType_UseOnlySuper)
100 #define USE_MAIN_PATH_2 (_useSuperPathType1 != kSuperPathType_UseOnlySuper && _useSuperPathType2 != kSuperPathType_UseOnlySuper)
101 
102 #define USE_SUPER_PATH (_useSuperPathType != kSuperPathType_UseOnlyMain)
103 #define USE_SUPER_PATH_2 (_useSuperPathType1 != kSuperPathType_UseOnlyMain || _useSuperPathType2 != kSuperPathType_UseOnlyMain)
104 
105 #define IF_USE_MAIN_PATH int _useSuperPathType = GetUseSuperPathType(path); if (USE_MAIN_PATH)
106 #define IF_USE_MAIN_PATH_2(x1, x2) \
107     int _useSuperPathType1 = GetUseSuperPathType(x1); \
108     int _useSuperPathType2 = GetUseSuperPathType(x2); \
109     if (USE_MAIN_PATH_2)
110 
111 #else
112 
113 #define IF_USE_MAIN_PATH
114 #define IF_USE_MAIN_PATH_2(x1, x2)
115 
116 #endif // Z7_LONG_PATH
117 
118 /*
119   if (dirPrefix != NULL && (path) is relative)
120   {
121     (dirPrefix) will be used
122     result (fullPath) will contain prefix part of (dirPrefix).
123   }
124   Current_Dir path can be used in 2 cases:
125     1) if (path) is relative && dirPrefix == NULL
126     2) for _WIN32: if (path) is absolute starting wuth "\"
127 */
128 bool GetFullPath(CFSTR dirPrefix, CFSTR path, FString &fullPath);
129 bool GetFullPath(CFSTR path, FString &fullPath);
130 
131 }}}
132 
133 #endif
134