1370b324cSopenharmony_ci// Windows/FileName.h
2370b324cSopenharmony_ci
3370b324cSopenharmony_ci#ifndef ZIP7_INC_WINDOWS_FILE_NAME_H
4370b324cSopenharmony_ci#define ZIP7_INC_WINDOWS_FILE_NAME_H
5370b324cSopenharmony_ci
6370b324cSopenharmony_ci#include "../Common/MyString.h"
7370b324cSopenharmony_ci
8370b324cSopenharmony_cinamespace NWindows {
9370b324cSopenharmony_cinamespace NFile {
10370b324cSopenharmony_cinamespace NName {
11370b324cSopenharmony_ci
12370b324cSopenharmony_ciint FindSepar(const wchar_t *s) throw();
13370b324cSopenharmony_ci#ifndef USE_UNICODE_FSTRING
14370b324cSopenharmony_ciint FindSepar(const FChar *s) throw();
15370b324cSopenharmony_ci#endif
16370b324cSopenharmony_ci
17370b324cSopenharmony_civoid NormalizeDirPathPrefix(FString &dirPath); // ensures that it ended with '\\', if dirPath is not epmty
18370b324cSopenharmony_civoid NormalizeDirPathPrefix(UString &dirPath);
19370b324cSopenharmony_ci
20370b324cSopenharmony_ci#ifdef _WIN32
21370b324cSopenharmony_civoid NormalizeDirSeparators(FString &s);
22370b324cSopenharmony_ci#endif
23370b324cSopenharmony_ci
24370b324cSopenharmony_cibool IsDrivePath(const wchar_t *s) throw();  // first 3 chars are drive chars like "a:\\"
25370b324cSopenharmony_ci
26370b324cSopenharmony_cibool IsAltPathPrefix(CFSTR s) throw(); /* name: */
27370b324cSopenharmony_ci
28370b324cSopenharmony_ci#if defined(_WIN32) && !defined(UNDER_CE)
29370b324cSopenharmony_ci
30370b324cSopenharmony_ciextern const char * const kSuperPathPrefix; /* \\?\ */
31370b324cSopenharmony_ciconst unsigned kDevicePathPrefixSize = 4;
32370b324cSopenharmony_ciconst unsigned kSuperPathPrefixSize = 4;
33370b324cSopenharmony_ciconst unsigned kSuperUncPathPrefixSize = kSuperPathPrefixSize + 4;
34370b324cSopenharmony_ci
35370b324cSopenharmony_cibool IsDevicePath(CFSTR s) throw();   /* \\.\ */
36370b324cSopenharmony_cibool IsSuperUncPath(CFSTR s) throw(); /* \\?\UNC\ */
37370b324cSopenharmony_cibool IsNetworkPath(CFSTR s) throw();  /* \\?\UNC\ or \\SERVER */
38370b324cSopenharmony_ci
39370b324cSopenharmony_ci/* GetNetworkServerPrefixSize() returns size of server prefix:
40370b324cSopenharmony_ci     \\?\UNC\SERVER\
41370b324cSopenharmony_ci     \\SERVER\
42370b324cSopenharmony_ci  in another cases it returns 0
43370b324cSopenharmony_ci*/
44370b324cSopenharmony_ci
45370b324cSopenharmony_ciunsigned GetNetworkServerPrefixSize(CFSTR s) throw();
46370b324cSopenharmony_ci
47370b324cSopenharmony_cibool IsNetworkShareRootPath(CFSTR s) throw();  /* \\?\UNC\SERVER\share or \\SERVER\share or with slash */
48370b324cSopenharmony_ci
49370b324cSopenharmony_cibool IsDrivePath_SuperAllowed(CFSTR s) throw();  // first chars are drive chars like "a:\" or "\\?\a:\"
50370b324cSopenharmony_cibool IsDriveRootPath_SuperAllowed(CFSTR s) throw();  // exact drive root path "a:\" or "\\?\a:\"
51370b324cSopenharmony_ci
52370b324cSopenharmony_cibool IsDrivePath2(const wchar_t *s) throw(); // first 2 chars are drive chars like "a:"
53370b324cSopenharmony_ci// bool IsDriveName2(const wchar_t *s) throw(); // is drive name like "a:"
54370b324cSopenharmony_cibool IsSuperPath(const wchar_t *s) throw();
55370b324cSopenharmony_cibool IsSuperOrDevicePath(const wchar_t *s) throw();
56370b324cSopenharmony_ci
57370b324cSopenharmony_cibool IsAltStreamPrefixWithColon(const UString &s) throw();
58370b324cSopenharmony_ci// returns true, if super prefix was removed
59370b324cSopenharmony_cibool If_IsSuperPath_RemoveSuperPrefix(UString &s);
60370b324cSopenharmony_ci
61370b324cSopenharmony_ci#ifndef USE_UNICODE_FSTRING
62370b324cSopenharmony_cibool IsDrivePath2(CFSTR s) throw(); // first 2 chars are drive chars like "a:"
63370b324cSopenharmony_ci// bool IsDriveName2(CFSTR s) throw(); // is drive name like "a:"
64370b324cSopenharmony_cibool IsDrivePath(CFSTR s) throw();
65370b324cSopenharmony_cibool IsSuperPath(CFSTR s) throw();
66370b324cSopenharmony_cibool IsSuperOrDevicePath(CFSTR s) throw();
67370b324cSopenharmony_ci
68370b324cSopenharmony_ci/* GetRootPrefixSize() returns size of ROOT PREFIX for cases:
69370b324cSopenharmony_ci     \
70370b324cSopenharmony_ci     \\.\
71370b324cSopenharmony_ci     C:\
72370b324cSopenharmony_ci     \\?\C:\
73370b324cSopenharmony_ci     \\?\UNC\SERVER\Shared\
74370b324cSopenharmony_ci     \\SERVER\Shared\
75370b324cSopenharmony_ci  in another cases it returns 0
76370b324cSopenharmony_ci*/
77370b324cSopenharmony_ci
78370b324cSopenharmony_ciunsigned GetRootPrefixSize(CFSTR s) throw();
79370b324cSopenharmony_ci
80370b324cSopenharmony_ci#endif
81370b324cSopenharmony_ci
82370b324cSopenharmony_ciint FindAltStreamColon(CFSTR path) throw();
83370b324cSopenharmony_ci
84370b324cSopenharmony_ci#endif // _WIN32
85370b324cSopenharmony_ci
86370b324cSopenharmony_cibool IsAbsolutePath(const wchar_t *s) throw();
87370b324cSopenharmony_ciunsigned GetRootPrefixSize(const wchar_t *s) throw();
88370b324cSopenharmony_ci
89370b324cSopenharmony_ci#ifdef Z7_LONG_PATH
90370b324cSopenharmony_ci
91370b324cSopenharmony_ciconst int kSuperPathType_UseOnlyMain = 0;
92370b324cSopenharmony_ciconst int kSuperPathType_UseOnlySuper = 1;
93370b324cSopenharmony_ciconst int kSuperPathType_UseMainAndSuper = 2;
94370b324cSopenharmony_ci
95370b324cSopenharmony_ciint GetUseSuperPathType(CFSTR s) throw();
96370b324cSopenharmony_cibool GetSuperPath(CFSTR path, UString &superPath, bool onlyIfNew);
97370b324cSopenharmony_cibool GetSuperPaths(CFSTR s1, CFSTR s2, UString &d1, UString &d2, bool onlyIfNew);
98370b324cSopenharmony_ci
99370b324cSopenharmony_ci#define USE_MAIN_PATH (_useSuperPathType != kSuperPathType_UseOnlySuper)
100370b324cSopenharmony_ci#define USE_MAIN_PATH_2 (_useSuperPathType1 != kSuperPathType_UseOnlySuper && _useSuperPathType2 != kSuperPathType_UseOnlySuper)
101370b324cSopenharmony_ci
102370b324cSopenharmony_ci#define USE_SUPER_PATH (_useSuperPathType != kSuperPathType_UseOnlyMain)
103370b324cSopenharmony_ci#define USE_SUPER_PATH_2 (_useSuperPathType1 != kSuperPathType_UseOnlyMain || _useSuperPathType2 != kSuperPathType_UseOnlyMain)
104370b324cSopenharmony_ci
105370b324cSopenharmony_ci#define IF_USE_MAIN_PATH int _useSuperPathType = GetUseSuperPathType(path); if (USE_MAIN_PATH)
106370b324cSopenharmony_ci#define IF_USE_MAIN_PATH_2(x1, x2) \
107370b324cSopenharmony_ci    int _useSuperPathType1 = GetUseSuperPathType(x1); \
108370b324cSopenharmony_ci    int _useSuperPathType2 = GetUseSuperPathType(x2); \
109370b324cSopenharmony_ci    if (USE_MAIN_PATH_2)
110370b324cSopenharmony_ci
111370b324cSopenharmony_ci#else
112370b324cSopenharmony_ci
113370b324cSopenharmony_ci#define IF_USE_MAIN_PATH
114370b324cSopenharmony_ci#define IF_USE_MAIN_PATH_2(x1, x2)
115370b324cSopenharmony_ci
116370b324cSopenharmony_ci#endif // Z7_LONG_PATH
117370b324cSopenharmony_ci
118370b324cSopenharmony_ci/*
119370b324cSopenharmony_ci  if (dirPrefix != NULL && (path) is relative)
120370b324cSopenharmony_ci  {
121370b324cSopenharmony_ci    (dirPrefix) will be used
122370b324cSopenharmony_ci    result (fullPath) will contain prefix part of (dirPrefix).
123370b324cSopenharmony_ci  }
124370b324cSopenharmony_ci  Current_Dir path can be used in 2 cases:
125370b324cSopenharmony_ci    1) if (path) is relative && dirPrefix == NULL
126370b324cSopenharmony_ci    2) for _WIN32: if (path) is absolute starting wuth "\"
127370b324cSopenharmony_ci*/
128370b324cSopenharmony_cibool GetFullPath(CFSTR dirPrefix, CFSTR path, FString &fullPath);
129370b324cSopenharmony_cibool GetFullPath(CFSTR path, FString &fullPath);
130370b324cSopenharmony_ci
131370b324cSopenharmony_ci}}}
132370b324cSopenharmony_ci
133370b324cSopenharmony_ci#endif
134