diff options
Diffstat (limited to 'CPP/Windows/FileIO.h')
| -rw-r--r-- | CPP/Windows/FileIO.h | 45 |
1 files changed, 43 insertions, 2 deletions
diff --git a/CPP/Windows/FileIO.h b/CPP/Windows/FileIO.h index a202df5..9c32137 100644 --- a/CPP/Windows/FileIO.h +++ b/CPP/Windows/FileIO.h | |||
| @@ -19,6 +19,27 @@ | |||
| 19 | #include <winioctl.h> | 19 | #include <winioctl.h> |
| 20 | #endif | 20 | #endif |
| 21 | 21 | ||
| 22 | typedef enum | ||
| 23 | { | ||
| 24 | Z7_WIN_FileDirectoryInformation = 1, | ||
| 25 | Z7_WIN_FileFullDirectoryInformation, | ||
| 26 | Z7_WIN_FileBothDirectoryInformation, | ||
| 27 | Z7_WIN_FileBasicInformation, | ||
| 28 | Z7_WIN_FileRenameInformation = 10 | ||
| 29 | } Z7_WIN_FILE_INFORMATION_CLASS; | ||
| 30 | |||
| 31 | // FILE_BASIC_INFORMATION / FILE_BASIC_INFO | ||
| 32 | typedef struct | ||
| 33 | { | ||
| 34 | LARGE_INTEGER CreationTime; | ||
| 35 | LARGE_INTEGER LastAccessTime; | ||
| 36 | LARGE_INTEGER LastWriteTime; | ||
| 37 | LARGE_INTEGER ChangeTime; | ||
| 38 | ULONG FileAttributes; | ||
| 39 | ULONG Reserved; // it's expected dummy variable for alignment : optional | ||
| 40 | } | ||
| 41 | Z7_WIN_FILE_BASIC_INFORMATION; | ||
| 42 | |||
| 22 | #else | 43 | #else |
| 23 | 44 | ||
| 24 | #include <sys/types.h> | 45 | #include <sys/types.h> |
| @@ -205,6 +226,9 @@ public: | |||
| 205 | return false; | 226 | return false; |
| 206 | return file.GetFileInformation(info); | 227 | return file.GetFileInformation(info); |
| 207 | } | 228 | } |
| 229 | |||
| 230 | DWORD Call_NtSetInformationFile_return_WinError(void *data, ULONG len, | ||
| 231 | Z7_WIN_FILE_INFORMATION_CLASS fileInformationClass) const; | ||
| 208 | }; | 232 | }; |
| 209 | 233 | ||
| 210 | #ifndef UNDER_CE | 234 | #ifndef UNDER_CE |
| @@ -323,6 +347,8 @@ public: | |||
| 323 | 347 | ||
| 324 | bool Create_ALWAYS_with_Attribs(CFSTR fileName, DWORD flagsAndAttributes); | 348 | bool Create_ALWAYS_with_Attribs(CFSTR fileName, DWORD flagsAndAttributes); |
| 325 | 349 | ||
| 350 | bool Set_Time_and_WinAttrib(const CFiTime *cTime, const CFiTime *aTime, const CFiTime *mTime, DWORD attrib) throw(); | ||
| 351 | |||
| 326 | bool SetTime(const CFiTime *cTime, const CFiTime *aTime, const CFiTime *mTime) throw(); | 352 | bool SetTime(const CFiTime *cTime, const CFiTime *aTime, const CFiTime *mTime) throw(); |
| 327 | bool SetMTime(const CFiTime *mTime) throw(); | 353 | bool SetMTime(const CFiTime *mTime) throw(); |
| 328 | bool WritePart(const void *data, UInt32 size, UInt32 &processedSize) throw(); | 354 | bool WritePart(const void *data, UInt32 size, UInt32 &processedSize) throw(); |
| @@ -338,6 +364,15 @@ public: | |||
| 338 | 364 | ||
| 339 | #else // _WIN32 | 365 | #else // _WIN32 |
| 340 | 366 | ||
| 367 | namespace NDir { | ||
| 368 | struct C_umask | ||
| 369 | { | ||
| 370 | mode_t mask; | ||
| 371 | C_umask(); | ||
| 372 | }; | ||
| 373 | extern C_umask g_umask; | ||
| 374 | } | ||
| 375 | |||
| 341 | namespace NIO { | 376 | namespace NIO { |
| 342 | 377 | ||
| 343 | bool GetReparseData(CFSTR path, CByteBuffer &reparseData); | 378 | bool GetReparseData(CFSTR path, CByteBuffer &reparseData); |
| @@ -347,6 +382,7 @@ bool GetReparseData(CFSTR path, CByteBuffer &reparseData); | |||
| 347 | bool SetSymLink(CFSTR from, CFSTR to); | 382 | bool SetSymLink(CFSTR from, CFSTR to); |
| 348 | bool SetSymLink_UString(CFSTR from, const UString &to); | 383 | bool SetSymLink_UString(CFSTR from, const UString &to); |
| 349 | 384 | ||
| 385 | const mode_t k_OutFile_mode_default = 0666; | ||
| 350 | 386 | ||
| 351 | class CFileBase | 387 | class CFileBase |
| 352 | { | 388 | { |
| @@ -359,7 +395,7 @@ protected: | |||
| 359 | UInt64 Size; // it can be larger than real available size | 395 | UInt64 Size; // it can be larger than real available size |
| 360 | */ | 396 | */ |
| 361 | 397 | ||
| 362 | bool OpenBinary(const char *name, int flags, mode_t mode = 0666); | 398 | bool OpenBinary(const char *name, int flags, mode_t mode /* = k_OutFile_mode_default */); |
| 363 | public: | 399 | public: |
| 364 | bool PreserveATime; | 400 | bool PreserveATime; |
| 365 | #if 0 | 401 | #if 0 |
| @@ -411,9 +447,11 @@ class COutFile: public CFileBase | |||
| 411 | bool CTime_defined; | 447 | bool CTime_defined; |
| 412 | bool ATime_defined; | 448 | bool ATime_defined; |
| 413 | bool MTime_defined; | 449 | bool MTime_defined; |
| 450 | bool mode_for_Close_defined; | ||
| 414 | CFiTime CTime; | 451 | CFiTime CTime; |
| 415 | CFiTime ATime; | 452 | CFiTime ATime; |
| 416 | CFiTime MTime; | 453 | CFiTime MTime; |
| 454 | mode_t mode_for_Close; | ||
| 417 | 455 | ||
| 418 | AString Path; | 456 | AString Path; |
| 419 | ssize_t write_part(const void *data, size_t size) throw(); | 457 | ssize_t write_part(const void *data, size_t size) throw(); |
| @@ -425,9 +463,11 @@ public: | |||
| 425 | CTime_defined(false), | 463 | CTime_defined(false), |
| 426 | ATime_defined(false), | 464 | ATime_defined(false), |
| 427 | MTime_defined(false), | 465 | MTime_defined(false), |
| 428 | mode_for_Create(0666) | 466 | mode_for_Close_defined(false), |
| 467 | mode_for_Create(k_OutFile_mode_default) // 0666 | ||
| 429 | {} | 468 | {} |
| 430 | 469 | ||
| 470 | ~COutFile() { Close(); } | ||
| 431 | bool Close(); | 471 | bool Close(); |
| 432 | 472 | ||
| 433 | bool Open_EXISTING(CFSTR fileName); | 473 | bool Open_EXISTING(CFSTR fileName); |
| @@ -454,6 +494,7 @@ public: | |||
| 454 | return SetLength(length); | 494 | return SetLength(length); |
| 455 | } | 495 | } |
| 456 | bool SetTime(const CFiTime *cTime, const CFiTime *aTime, const CFiTime *mTime) throw(); | 496 | bool SetTime(const CFiTime *cTime, const CFiTime *aTime, const CFiTime *mTime) throw(); |
| 497 | bool Set_Time_and_WinAttrib(const CFiTime *cTime, const CFiTime *aTime, const CFiTime *mTime, DWORD attrib) throw(); | ||
| 457 | bool SetMTime(const CFiTime *mTime) throw(); | 498 | bool SetMTime(const CFiTime *mTime) throw(); |
| 458 | }; | 499 | }; |
| 459 | 500 | ||
