diff options
Diffstat (limited to 'CPP/Windows/FileIO.h')
-rw-r--r-- | CPP/Windows/FileIO.h | 51 |
1 files changed, 32 insertions, 19 deletions
diff --git a/CPP/Windows/FileIO.h b/CPP/Windows/FileIO.h index 8050965..03e061a 100644 --- a/CPP/Windows/FileIO.h +++ b/CPP/Windows/FileIO.h | |||
@@ -1,23 +1,23 @@ | |||
1 | // Windows/FileIO.h | 1 | // Windows/FileIO.h |
2 | 2 | ||
3 | #ifndef __WINDOWS_FILE_IO_H | 3 | #ifndef ZIP7_INC_WINDOWS_FILE_IO_H |
4 | #define __WINDOWS_FILE_IO_H | 4 | #define ZIP7_INC_WINDOWS_FILE_IO_H |
5 | 5 | ||
6 | #include "../Common/MyWindows.h" | 6 | #include "../Common/MyWindows.h" |
7 | 7 | ||
8 | #define _my_IO_REPARSE_TAG_MOUNT_POINT (0xA0000003L) | 8 | #define Z7_WIN_IO_REPARSE_TAG_MOUNT_POINT (0xA0000003L) |
9 | #define _my_IO_REPARSE_TAG_SYMLINK (0xA000000CL) | 9 | #define Z7_WIN_IO_REPARSE_TAG_SYMLINK (0xA000000CL) |
10 | #define _my_IO_REPARSE_TAG_LX_SYMLINK (0xA000001DL) | 10 | #define Z7_WIN_IO_REPARSE_TAG_LX_SYMLINK (0xA000001DL) |
11 | 11 | ||
12 | #define _my_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 | // what the meaning of that FLAG or field (2)? |
15 | #define _my_LX_SYMLINK_FLAG 2 | 15 | #define Z7_WIN_LX_SYMLINK_FLAG 2 |
16 | 16 | ||
17 | #ifdef _WIN32 | 17 | #ifdef _WIN32 |
18 | 18 | ||
19 | #if defined(_WIN32) && !defined(UNDER_CE) | 19 | #if defined(_WIN32) && !defined(UNDER_CE) |
20 | #include <WinIoCtl.h> | 20 | #include <winioctl.h> |
21 | #endif | 21 | #endif |
22 | 22 | ||
23 | #else | 23 | #else |
@@ -76,11 +76,11 @@ struct CReparseAttr | |||
76 | // returns (false) and (ErrorCode = ERROR_REPARSE_TAG_INVALID), if unknown tag | 76 | // returns (false) and (ErrorCode = ERROR_REPARSE_TAG_INVALID), if unknown tag |
77 | bool Parse(const Byte *p, size_t size); | 77 | bool Parse(const Byte *p, size_t size); |
78 | 78 | ||
79 | bool IsMountPoint() const { return Tag == _my_IO_REPARSE_TAG_MOUNT_POINT; } // it's Junction | 79 | bool IsMountPoint() const { return Tag == Z7_WIN_IO_REPARSE_TAG_MOUNT_POINT; } // it's Junction |
80 | bool IsSymLink_Win() const { return Tag == _my_IO_REPARSE_TAG_SYMLINK; } | 80 | bool IsSymLink_Win() const { return Tag == Z7_WIN_IO_REPARSE_TAG_SYMLINK; } |
81 | bool IsSymLink_WSL() const { return Tag == _my_IO_REPARSE_TAG_LX_SYMLINK; } | 81 | bool IsSymLink_WSL() const { return Tag == Z7_WIN_IO_REPARSE_TAG_LX_SYMLINK; } |
82 | 82 | ||
83 | bool IsRelative_Win() const { return Flags == _my_SYMLINK_FLAG_RELATIVE; } | 83 | bool IsRelative_Win() const { return Flags == Z7_WIN_SYMLINK_FLAG_RELATIVE; } |
84 | 84 | ||
85 | bool IsRelative_WSL() const | 85 | bool IsRelative_WSL() const |
86 | { | 86 | { |
@@ -141,17 +141,19 @@ public: | |||
141 | 141 | ||
142 | public: | 142 | public: |
143 | bool PreserveATime; | 143 | bool PreserveATime; |
144 | #ifdef SUPPORT_DEVICE_FILE | 144 | #ifdef Z7_DEVICE_FILE |
145 | bool IsDeviceFile; | 145 | bool IsDeviceFile; |
146 | bool SizeDefined; | 146 | bool SizeDefined; |
147 | UInt64 Size; // it can be larger than real available size | 147 | UInt64 Size; // it can be larger than real available size |
148 | #endif | 148 | #endif |
149 | 149 | ||
150 | CFileBase(): _handle(INVALID_HANDLE_VALUE), PreserveATime(false) {}; | 150 | CFileBase(): _handle(INVALID_HANDLE_VALUE), PreserveATime(false) {} |
151 | ~CFileBase() { Close(); } | 151 | ~CFileBase() { Close(); } |
152 | 152 | ||
153 | HANDLE GetHandle() const { return _handle; } | 153 | HANDLE GetHandle() const { return _handle; } |
154 | 154 | ||
155 | // void Detach() { _handle = INVALID_HANDLE_VALUE; } | ||
156 | |||
155 | bool Close() throw(); | 157 | bool Close() throw(); |
156 | 158 | ||
157 | bool GetPosition(UInt64 &position) const throw(); | 159 | bool GetPosition(UInt64 &position) const throw(); |
@@ -193,7 +195,7 @@ struct my_DISK_GEOMETRY_EX | |||
193 | 195 | ||
194 | class CInFile: public CFileBase | 196 | class CInFile: public CFileBase |
195 | { | 197 | { |
196 | #ifdef SUPPORT_DEVICE_FILE | 198 | #ifdef Z7_DEVICE_FILE |
197 | 199 | ||
198 | #ifndef UNDER_CE | 200 | #ifndef UNDER_CE |
199 | 201 | ||
@@ -232,6 +234,14 @@ public: | |||
232 | // we must use (FILE_FLAG_BACKUP_SEMANTICS) to open handle of directory. | 234 | // we must use (FILE_FLAG_BACKUP_SEMANTICS) to open handle of directory. |
233 | } | 235 | } |
234 | 236 | ||
237 | bool Open_for_FileRenameInformation(CFSTR fileName) | ||
238 | { | ||
239 | return Create(fileName, DELETE | SYNCHRONIZE | GENERIC_READ, | ||
240 | FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, | ||
241 | OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL); | ||
242 | // we must use (FILE_FLAG_BACKUP_SEMANTICS) to open handle of directory. | ||
243 | } | ||
244 | |||
235 | bool OpenReparse(CFSTR fileName) | 245 | bool OpenReparse(CFSTR fileName) |
236 | { | 246 | { |
237 | // 17.02 fix: to support Windows XP compatibility junctions: | 247 | // 17.02 fix: to support Windows XP compatibility junctions: |
@@ -295,12 +305,13 @@ protected: | |||
295 | UInt64 Size; // it can be larger than real available size | 305 | UInt64 Size; // it can be larger than real available size |
296 | */ | 306 | */ |
297 | 307 | ||
298 | bool OpenBinary(const char *name, int flags); | 308 | bool OpenBinary(const char *name, int flags, mode_t mode = 0666); |
299 | public: | 309 | public: |
300 | bool PreserveATime; | 310 | bool PreserveATime; |
301 | 311 | ||
302 | CFileBase(): _handle(-1), PreserveATime(false) {}; | 312 | CFileBase(): _handle(-1), PreserveATime(false) {} |
303 | ~CFileBase() { Close(); } | 313 | ~CFileBase() { Close(); } |
314 | // void Detach() { _handle = -1; } | ||
304 | bool Close(); | 315 | bool Close(); |
305 | bool GetLength(UInt64 &length) const; | 316 | bool GetLength(UInt64 &length) const; |
306 | off_t seek(off_t distanceToMove, int moveMethod) const; | 317 | off_t seek(off_t distanceToMove, int moveMethod) const; |
@@ -330,7 +341,6 @@ class COutFile: public CFileBase | |||
330 | bool CTime_defined; | 341 | bool CTime_defined; |
331 | bool ATime_defined; | 342 | bool ATime_defined; |
332 | bool MTime_defined; | 343 | bool MTime_defined; |
333 | |||
334 | CFiTime CTime; | 344 | CFiTime CTime; |
335 | CFiTime ATime; | 345 | CFiTime ATime; |
336 | CFiTime MTime; | 346 | CFiTime MTime; |
@@ -338,10 +348,13 @@ class COutFile: public CFileBase | |||
338 | AString Path; | 348 | AString Path; |
339 | ssize_t write_part(const void *data, size_t size) throw(); | 349 | ssize_t write_part(const void *data, size_t size) throw(); |
340 | public: | 350 | public: |
351 | mode_t mode_for_Create; | ||
352 | |||
341 | COutFile(): | 353 | COutFile(): |
342 | CTime_defined(false), | 354 | CTime_defined(false), |
343 | ATime_defined(false), | 355 | ATime_defined(false), |
344 | MTime_defined(false) | 356 | MTime_defined(false), |
357 | mode_for_Create(0666) | ||
345 | {} | 358 | {} |
346 | 359 | ||
347 | bool Close(); | 360 | bool Close(); |