diff options
Diffstat (limited to '')
-rw-r--r-- | CPP/Windows/FileIO.h | 43 |
1 files changed, 31 insertions, 12 deletions
diff --git a/CPP/Windows/FileIO.h b/CPP/Windows/FileIO.h index 6ba40eb..26edef4 100644 --- a/CPP/Windows/FileIO.h +++ b/CPP/Windows/FileIO.h | |||
@@ -11,8 +11,7 @@ | |||
11 | 11 | ||
12 | #define Z7_WIN_SYMLINK_FLAG_RELATIVE 1 | 12 | #define Z7_WIN_SYMLINK_FLAG_RELATIVE 1 |
13 | 13 | ||
14 | // what the meaning of that FLAG or field (2)? | 14 | #define Z7_WIN_LX_SYMLINK_VERSION_2 2 |
15 | #define Z7_WIN_LX_SYMLINK_FLAG 2 | ||
16 | 15 | ||
17 | #ifdef _WIN32 | 16 | #ifdef _WIN32 |
18 | 17 | ||
@@ -44,7 +43,33 @@ namespace NWindows { | |||
44 | namespace NFile { | 43 | namespace NFile { |
45 | 44 | ||
46 | #if defined(_WIN32) && !defined(UNDER_CE) | 45 | #if defined(_WIN32) && !defined(UNDER_CE) |
47 | bool FillLinkData(CByteBuffer &dest, const wchar_t *path, bool isSymLink, bool isWSL); | 46 | /* |
47 | in: (CByteBuffer &dest) is empty | ||
48 | in: (path) uses Windows path separator (\). | ||
49 | out: (path) uses Linux path separator (/). | ||
50 | if (isAbsPath == true), then "c:\\" prefix is replaced to "/mnt/c/" prefix | ||
51 | */ | ||
52 | void Convert_WinPath_to_WslLinuxPath(FString &path, bool convertDrivePath); | ||
53 | // (path) must use Linux path separator (/). | ||
54 | void FillLinkData_WslLink(CByteBuffer &dest, const wchar_t *path); | ||
55 | |||
56 | /* | ||
57 | in: (CByteBuffer &dest) is empty | ||
58 | if (isSymLink == false) : MOUNT_POINT : (path) must be absolute. | ||
59 | if (isSymLink == true) : SYMLINK : Windows | ||
60 | (path) must use Windows path separator (\). | ||
61 | (path) must be without link "\\??\\" prefix. | ||
62 | link "\\??\\" prefix will be added inside FillLinkData(), if path is absolute. | ||
63 | */ | ||
64 | void FillLinkData_WinLink(CByteBuffer &dest, const wchar_t *path, bool isSymLink); | ||
65 | // in: (CByteBuffer &dest) is empty | ||
66 | inline void FillLinkData(CByteBuffer &dest, const wchar_t *path, bool isSymLink, bool isWSL) | ||
67 | { | ||
68 | if (isWSL) | ||
69 | FillLinkData_WslLink(dest, path); | ||
70 | else | ||
71 | FillLinkData_WinLink(dest, path, isSymLink); | ||
72 | } | ||
48 | #endif | 73 | #endif |
49 | 74 | ||
50 | struct CReparseShortInfo | 75 | struct CReparseShortInfo |
@@ -61,7 +86,6 @@ struct CReparseAttr | |||
61 | UInt32 Flags; | 86 | UInt32 Flags; |
62 | UString SubsName; | 87 | UString SubsName; |
63 | UString PrintName; | 88 | UString PrintName; |
64 | |||
65 | AString WslName; | 89 | AString WslName; |
66 | 90 | ||
67 | bool HeaderError; | 91 | bool HeaderError; |
@@ -71,8 +95,7 @@ struct CReparseAttr | |||
71 | 95 | ||
72 | CReparseAttr(): Tag(0), Flags(0) {} | 96 | CReparseAttr(): Tag(0), Flags(0) {} |
73 | 97 | ||
74 | // Parse() | 98 | // returns (true) and (ErrorCode = 0), if (it's correct known link) |
75 | // returns (true) and (ErrorCode = 0), if (it'a correct known link) | ||
76 | // returns (false) and (ErrorCode = ERROR_REPARSE_TAG_INVALID), if unknown tag | 99 | // returns (false) and (ErrorCode = ERROR_REPARSE_TAG_INVALID), if unknown tag |
77 | bool Parse(const Byte *p, size_t size); | 100 | bool Parse(const Byte *p, size_t size); |
78 | 101 | ||
@@ -80,18 +103,14 @@ struct CReparseAttr | |||
80 | bool IsSymLink_Win() const { return Tag == Z7_WIN_IO_REPARSE_TAG_SYMLINK; } | 103 | bool IsSymLink_Win() const { return Tag == Z7_WIN_IO_REPARSE_TAG_SYMLINK; } |
81 | bool IsSymLink_WSL() const { return Tag == Z7_WIN_IO_REPARSE_TAG_LX_SYMLINK; } | 104 | bool IsSymLink_WSL() const { return Tag == Z7_WIN_IO_REPARSE_TAG_LX_SYMLINK; } |
82 | 105 | ||
106 | // note: "/dir1/path" is marked as relative. | ||
83 | bool IsRelative_Win() const { return Flags == Z7_WIN_SYMLINK_FLAG_RELATIVE; } | 107 | bool IsRelative_Win() const { return Flags == Z7_WIN_SYMLINK_FLAG_RELATIVE; } |
84 | 108 | ||
85 | bool IsRelative_WSL() const | 109 | bool IsRelative_WSL() const |
86 | { | 110 | { |
87 | if (WslName.IsEmpty()) | 111 | return WslName[0] != '/'; // WSL uses unix path separator |
88 | return true; | ||
89 | char c = WslName[0]; | ||
90 | return !IS_PATH_SEPAR(c); | ||
91 | } | 112 | } |
92 | 113 | ||
93 | // bool IsVolume() const; | ||
94 | |||
95 | bool IsOkNamePair() const; | 114 | bool IsOkNamePair() const; |
96 | UString GetPath() const; | 115 | UString GetPath() const; |
97 | }; | 116 | }; |