aboutsummaryrefslogtreecommitdiff
path: root/CPP/Windows/FileName.h
diff options
context:
space:
mode:
Diffstat (limited to 'CPP/Windows/FileName.h')
-rw-r--r--CPP/Windows/FileName.h119
1 files changed, 119 insertions, 0 deletions
diff --git a/CPP/Windows/FileName.h b/CPP/Windows/FileName.h
new file mode 100644
index 0000000..de8bd13
--- /dev/null
+++ b/CPP/Windows/FileName.h
@@ -0,0 +1,119 @@
1// Windows/FileName.h
2
3#ifndef __WINDOWS_FILE_NAME_H
4#define __WINDOWS_FILE_NAME_H
5
6#include "../Common/MyString.h"
7
8namespace NWindows {
9namespace NFile {
10namespace NName {
11
12int FindSepar(const wchar_t *s) throw();
13#ifndef USE_UNICODE_FSTRING
14int FindSepar(const FChar *s) throw();
15#endif
16
17void NormalizeDirPathPrefix(FString &dirPath); // ensures that it ended with '\\', if dirPath is not epmty
18void NormalizeDirPathPrefix(UString &dirPath);
19
20#ifdef _WIN32
21void NormalizeDirSeparators(FString &s);
22#endif
23
24bool IsDrivePath(const wchar_t *s) throw(); // first 3 chars are drive chars like "a:\\"
25
26bool IsAltPathPrefix(CFSTR s) throw(); /* name: */
27
28#if defined(_WIN32) && !defined(UNDER_CE)
29
30extern const char * const kSuperPathPrefix; /* \\?\ */
31const unsigned kDevicePathPrefixSize = 4;
32const unsigned kSuperPathPrefixSize = 4;
33const unsigned kSuperUncPathPrefixSize = kSuperPathPrefixSize + 4;
34
35bool IsDevicePath(CFSTR s) throw(); /* \\.\ */
36bool IsSuperUncPath(CFSTR s) throw(); /* \\?\UNC\ */
37bool 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
45unsigned GetNetworkServerPrefixSize(CFSTR s) throw();
46
47bool IsNetworkShareRootPath(CFSTR s) throw(); /* \\?\UNC\SERVER\share or \\SERVER\share or with slash */
48
49bool IsDrivePath_SuperAllowed(CFSTR s) throw(); // first chars are drive chars like "a:\" or "\\?\a:\"
50bool IsDriveRootPath_SuperAllowed(CFSTR s) throw(); // exact drive root path "a:\" or "\\?\a:\"
51
52bool 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:"
54bool IsSuperPath(const wchar_t *s) throw();
55bool IsSuperOrDevicePath(const wchar_t *s) throw();
56
57#ifndef USE_UNICODE_FSTRING
58bool IsDrivePath2(CFSTR s) throw(); // first 2 chars are drive chars like "a:"
59// bool IsDriveName2(CFSTR s) throw(); // is drive name like "a:"
60bool IsDrivePath(CFSTR s) throw();
61bool IsSuperPath(CFSTR s) throw();
62bool 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
74unsigned GetRootPrefixSize(CFSTR s) throw();
75
76#endif
77
78int FindAltStreamColon(CFSTR path) throw();
79
80#endif // _WIN32
81
82bool IsAbsolutePath(const wchar_t *s) throw();
83unsigned GetRootPrefixSize(const wchar_t *s) throw();
84
85#ifdef WIN_LONG_PATH
86
87const int kSuperPathType_UseOnlyMain = 0;
88const int kSuperPathType_UseOnlySuper = 1;
89const int kSuperPathType_UseMainAndSuper = 2;
90
91int GetUseSuperPathType(CFSTR s) throw();
92bool GetSuperPath(CFSTR path, UString &superPath, bool onlyIfNew);
93bool 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
114bool GetFullPath(CFSTR dirPrefix, CFSTR path, FString &fullPath);
115bool GetFullPath(CFSTR path, FString &fullPath);
116
117}}}
118
119#endif