diff options
Diffstat (limited to '')
-rw-r--r-- | CPP/Windows/FileLink.cpp | 79 |
1 files changed, 44 insertions, 35 deletions
diff --git a/CPP/Windows/FileLink.cpp b/CPP/Windows/FileLink.cpp index 8ce634f..2b9fa1a 100644 --- a/CPP/Windows/FileLink.cpp +++ b/CPP/Windows/FileLink.cpp | |||
@@ -8,7 +8,7 @@ | |||
8 | #include <unistd.h> | 8 | #include <unistd.h> |
9 | #endif | 9 | #endif |
10 | 10 | ||
11 | #ifdef SUPPORT_DEVICE_FILE | 11 | #ifdef Z7_DEVICE_FILE |
12 | #include "../../C/Alloc.h" | 12 | #include "../../C/Alloc.h" |
13 | #endif | 13 | #endif |
14 | 14 | ||
@@ -20,6 +20,15 @@ | |||
20 | #include "FileIO.h" | 20 | #include "FileIO.h" |
21 | #include "FileName.h" | 21 | #include "FileName.h" |
22 | 22 | ||
23 | #ifdef Z7_OLD_WIN_SDK | ||
24 | #ifndef ERROR_INVALID_REPARSE_DATA | ||
25 | #define ERROR_INVALID_REPARSE_DATA 4392L | ||
26 | #endif | ||
27 | #ifndef ERROR_REPARSE_TAG_INVALID | ||
28 | #define ERROR_REPARSE_TAG_INVALID 4393L | ||
29 | #endif | ||
30 | #endif | ||
31 | |||
23 | #ifndef _UNICODE | 32 | #ifndef _UNICODE |
24 | extern bool g_IsNT; | 33 | extern bool g_IsNT; |
25 | #endif | 34 | #endif |
@@ -72,13 +81,13 @@ static const UInt32 kReparseFlags_Alias = (1 << 29); | |||
72 | static const UInt32 kReparseFlags_HighLatency = (1 << 30); | 81 | static const UInt32 kReparseFlags_HighLatency = (1 << 30); |
73 | static const UInt32 kReparseFlags_Microsoft = ((UInt32)1 << 31); | 82 | static const UInt32 kReparseFlags_Microsoft = ((UInt32)1 << 31); |
74 | 83 | ||
75 | #define _my_IO_REPARSE_TAG_HSM (0xC0000004L) | 84 | #define Z7_WIN_IO_REPARSE_TAG_HSM (0xC0000004L) |
76 | #define _my_IO_REPARSE_TAG_HSM2 (0x80000006L) | 85 | #define Z7_WIN_IO_REPARSE_TAG_HSM2 (0x80000006L) |
77 | #define _my_IO_REPARSE_TAG_SIS (0x80000007L) | 86 | #define Z7_WIN_IO_REPARSE_TAG_SIS (0x80000007L) |
78 | #define _my_IO_REPARSE_TAG_WIM (0x80000008L) | 87 | #define Z7_WIN_IO_REPARSE_TAG_WIM (0x80000008L) |
79 | #define _my_IO_REPARSE_TAG_CSV (0x80000009L) | 88 | #define Z7_WIN_IO_REPARSE_TAG_CSV (0x80000009L) |
80 | #define _my_IO_REPARSE_TAG_DFS (0x8000000AL) | 89 | #define Z7_WIN_IO_REPARSE_TAG_DFS (0x8000000AL) |
81 | #define _my_IO_REPARSE_TAG_DFSR (0x80000012L) | 90 | #define Z7_WIN_IO_REPARSE_TAG_DFSR (0x80000012L) |
82 | */ | 91 | */ |
83 | 92 | ||
84 | #define Get16(p) GetUi16(p) | 93 | #define Get16(p) GetUi16(p) |
@@ -112,7 +121,7 @@ static void WriteString(Byte *dest, const wchar_t *path) | |||
112 | wchar_t c = *path++; | 121 | wchar_t c = *path++; |
113 | if (c == 0) | 122 | if (c == 0) |
114 | return; | 123 | return; |
115 | Set16(dest, (UInt16)c); | 124 | Set16(dest, (UInt16)c) |
116 | dest += 2; | 125 | dest += 2; |
117 | } | 126 | } |
118 | } | 127 | } |
@@ -133,10 +142,10 @@ bool FillLinkData(CByteBuffer &dest, const wchar_t *path, bool isSymLink, bool i | |||
133 | return false; | 142 | return false; |
134 | dest.Alloc(8 + size); | 143 | dest.Alloc(8 + size); |
135 | Byte *p = dest; | 144 | Byte *p = dest; |
136 | Set32(p, _my_IO_REPARSE_TAG_LX_SYMLINK); | 145 | Set32(p, Z7_WIN_IO_REPARSE_TAG_LX_SYMLINK) |
137 | Set16(p + 4, (UInt16)(size)); | 146 | Set16(p + 4, (UInt16)(size)) |
138 | Set16(p + 6, 0); | 147 | Set16(p + 6, 0) |
139 | Set32(p + 8, _my_LX_SYMLINK_FLAG); | 148 | Set32(p + 8, Z7_WIN_LX_SYMLINK_FLAG) |
140 | memcpy(p + 12, utf.Ptr(), utf.Len()); | 149 | memcpy(p + 12, utf.Ptr(), utf.Len()); |
141 | return true; | 150 | return true; |
142 | } | 151 | } |
@@ -176,12 +185,12 @@ bool FillLinkData(CByteBuffer &dest, const wchar_t *path, bool isSymLink, bool i | |||
176 | dest.Alloc(size); | 185 | dest.Alloc(size); |
177 | memset(dest, 0, size); | 186 | memset(dest, 0, size); |
178 | const UInt32 tag = isSymLink ? | 187 | const UInt32 tag = isSymLink ? |
179 | _my_IO_REPARSE_TAG_SYMLINK : | 188 | Z7_WIN_IO_REPARSE_TAG_SYMLINK : |
180 | _my_IO_REPARSE_TAG_MOUNT_POINT; | 189 | Z7_WIN_IO_REPARSE_TAG_MOUNT_POINT; |
181 | Byte *p = dest; | 190 | Byte *p = dest; |
182 | Set32(p, tag); | 191 | Set32(p, tag) |
183 | Set16(p + 4, (UInt16)(size - 8)); | 192 | Set16(p + 4, (UInt16)(size - 8)) |
184 | Set16(p + 6, 0); | 193 | Set16(p + 6, 0) |
185 | p += 8; | 194 | p += 8; |
186 | 195 | ||
187 | unsigned subOffs = 0; | 196 | unsigned subOffs = 0; |
@@ -191,16 +200,16 @@ bool FillLinkData(CByteBuffer &dest, const wchar_t *path, bool isSymLink, bool i | |||
191 | else | 200 | else |
192 | printOffs = (unsigned)len1 + 2; | 201 | printOffs = (unsigned)len1 + 2; |
193 | 202 | ||
194 | Set16(p + 0, (UInt16)subOffs); | 203 | Set16(p + 0, (UInt16)subOffs) |
195 | Set16(p + 2, (UInt16)len1); | 204 | Set16(p + 2, (UInt16)len1) |
196 | Set16(p + 4, (UInt16)printOffs); | 205 | Set16(p + 4, (UInt16)printOffs) |
197 | Set16(p + 6, (UInt16)len2); | 206 | Set16(p + 6, (UInt16)len2) |
198 | 207 | ||
199 | p += 8; | 208 | p += 8; |
200 | if (isSymLink) | 209 | if (isSymLink) |
201 | { | 210 | { |
202 | UInt32 flags = isAbs ? 0 : _my_SYMLINK_FLAG_RELATIVE; | 211 | UInt32 flags = isAbs ? 0 : Z7_WIN_SYMLINK_FLAG_RELATIVE; |
203 | Set32(p, flags); | 212 | Set32(p, flags) |
204 | p += 4; | 213 | p += 4; |
205 | } | 214 | } |
206 | 215 | ||
@@ -255,9 +264,9 @@ bool CReparseAttr::Parse(const Byte *p, size_t size) | |||
255 | 264 | ||
256 | HeaderError = false; | 265 | HeaderError = false; |
257 | 266 | ||
258 | if ( Tag != _my_IO_REPARSE_TAG_MOUNT_POINT | 267 | if ( Tag != Z7_WIN_IO_REPARSE_TAG_MOUNT_POINT |
259 | && Tag != _my_IO_REPARSE_TAG_SYMLINK | 268 | && Tag != Z7_WIN_IO_REPARSE_TAG_SYMLINK |
260 | && Tag != _my_IO_REPARSE_TAG_LX_SYMLINK) | 269 | && Tag != Z7_WIN_IO_REPARSE_TAG_LX_SYMLINK) |
261 | { | 270 | { |
262 | // for unsupported reparse points | 271 | // for unsupported reparse points |
263 | ErrorCode = (DWORD)ERROR_REPARSE_TAG_INVALID; // ERROR_REPARSE_TAG_MISMATCH | 272 | ErrorCode = (DWORD)ERROR_REPARSE_TAG_INVALID; // ERROR_REPARSE_TAG_MISMATCH |
@@ -270,12 +279,12 @@ bool CReparseAttr::Parse(const Byte *p, size_t size) | |||
270 | p += 8; | 279 | p += 8; |
271 | size -= 8; | 280 | size -= 8; |
272 | 281 | ||
273 | if (Tag == _my_IO_REPARSE_TAG_LX_SYMLINK) | 282 | if (Tag == Z7_WIN_IO_REPARSE_TAG_LX_SYMLINK) |
274 | { | 283 | { |
275 | if (len < 4) | 284 | if (len < 4) |
276 | return false; | 285 | return false; |
277 | Flags = Get32(p); // maybe it's not Flags | 286 | Flags = Get32(p); // maybe it's not Flags |
278 | if (Flags != _my_LX_SYMLINK_FLAG) | 287 | if (Flags != Z7_WIN_LX_SYMLINK_FLAG) |
279 | return false; | 288 | return false; |
280 | len -= 4; | 289 | len -= 4; |
281 | p += 4; | 290 | p += 4; |
@@ -304,7 +313,7 @@ bool CReparseAttr::Parse(const Byte *p, size_t size) | |||
304 | p += 8; | 313 | p += 8; |
305 | 314 | ||
306 | Flags = 0; | 315 | Flags = 0; |
307 | if (Tag == _my_IO_REPARSE_TAG_SYMLINK) | 316 | if (Tag == Z7_WIN_IO_REPARSE_TAG_SYMLINK) |
308 | { | 317 | { |
309 | if (len < 4) | 318 | if (len < 4) |
310 | return false; | 319 | return false; |
@@ -341,8 +350,8 @@ bool CReparseShortInfo::Parse(const Byte *p, size_t size) | |||
341 | (type & kReparseFlags_Microsoft) == 0 || | 350 | (type & kReparseFlags_Microsoft) == 0 || |
342 | (type & 0xFFFF) != 3) | 351 | (type & 0xFFFF) != 3) |
343 | */ | 352 | */ |
344 | if (Tag != _my_IO_REPARSE_TAG_MOUNT_POINT && | 353 | if (Tag != Z7_WIN_IO_REPARSE_TAG_MOUNT_POINT && |
345 | Tag != _my_IO_REPARSE_TAG_SYMLINK) | 354 | Tag != Z7_WIN_IO_REPARSE_TAG_SYMLINK) |
346 | // return true; | 355 | // return true; |
347 | return false; | 356 | return false; |
348 | 357 | ||
@@ -365,7 +374,7 @@ bool CReparseShortInfo::Parse(const Byte *p, size_t size) | |||
365 | p += 8; | 374 | p += 8; |
366 | 375 | ||
367 | // UInt32 Flags = 0; | 376 | // UInt32 Flags = 0; |
368 | if (Tag == _my_IO_REPARSE_TAG_SYMLINK) | 377 | if (Tag == Z7_WIN_IO_REPARSE_TAG_SYMLINK) |
369 | { | 378 | { |
370 | if (len < 4) | 379 | if (len < 4) |
371 | return false; | 380 | return false; |
@@ -426,13 +435,13 @@ UString CReparseAttr::GetPath() const | |||
426 | return s; | 435 | return s; |
427 | } | 436 | } |
428 | 437 | ||
429 | #ifdef SUPPORT_DEVICE_FILE | 438 | #ifdef Z7_DEVICE_FILE |
430 | 439 | ||
431 | namespace NSystem | 440 | namespace NSystem |
432 | { | 441 | { |
433 | bool MyGetDiskFreeSpace(CFSTR rootPath, UInt64 &clusterSize, UInt64 &totalSize, UInt64 &freeSize); | 442 | bool MyGetDiskFreeSpace(CFSTR rootPath, UInt64 &clusterSize, UInt64 &totalSize, UInt64 &freeSize); |
434 | } | 443 | } |
435 | #endif // SUPPORT_DEVICE_FILE | 444 | #endif // Z7_DEVICE_FILE |
436 | 445 | ||
437 | #if defined(_WIN32) && !defined(UNDER_CE) | 446 | #if defined(_WIN32) && !defined(UNDER_CE) |
438 | 447 | ||