diff options
Diffstat (limited to '')
-rw-r--r-- | CPP/Windows/FileIO.cpp | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/CPP/Windows/FileIO.cpp b/CPP/Windows/FileIO.cpp index e51b0eb..4ecbb7e 100644 --- a/CPP/Windows/FileIO.cpp +++ b/CPP/Windows/FileIO.cpp | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | #include "StdAfx.h" | 3 | #include "StdAfx.h" |
4 | 4 | ||
5 | #ifdef SUPPORT_DEVICE_FILE | 5 | #ifdef Z7_DEVICE_FILE |
6 | #include "../../C/Alloc.h" | 6 | #include "../../C/Alloc.h" |
7 | #endif | 7 | #endif |
8 | 8 | ||
@@ -21,7 +21,7 @@ | |||
21 | 21 | ||
22 | HRESULT GetLastError_noZero_HRESULT() | 22 | HRESULT GetLastError_noZero_HRESULT() |
23 | { | 23 | { |
24 | DWORD res = ::GetLastError(); | 24 | const DWORD res = ::GetLastError(); |
25 | if (res == 0) | 25 | if (res == 0) |
26 | return E_FAIL; | 26 | return E_FAIL; |
27 | return HRESULT_FROM_WIN32(res); | 27 | return HRESULT_FROM_WIN32(res); |
@@ -40,7 +40,7 @@ using namespace NName; | |||
40 | namespace NWindows { | 40 | namespace NWindows { |
41 | namespace NFile { | 41 | namespace NFile { |
42 | 42 | ||
43 | #ifdef SUPPORT_DEVICE_FILE | 43 | #ifdef Z7_DEVICE_FILE |
44 | 44 | ||
45 | namespace NSystem | 45 | namespace NSystem |
46 | { | 46 | { |
@@ -72,7 +72,7 @@ bool CFileBase::Create(CFSTR path, DWORD desiredAccess, | |||
72 | if (!Close()) | 72 | if (!Close()) |
73 | return false; | 73 | return false; |
74 | 74 | ||
75 | #ifdef SUPPORT_DEVICE_FILE | 75 | #ifdef Z7_DEVICE_FILE |
76 | IsDeviceFile = false; | 76 | IsDeviceFile = false; |
77 | #endif | 77 | #endif |
78 | 78 | ||
@@ -88,7 +88,7 @@ bool CFileBase::Create(CFSTR path, DWORD desiredAccess, | |||
88 | IF_USE_MAIN_PATH | 88 | IF_USE_MAIN_PATH |
89 | _handle = ::CreateFileW(fs2us(path), desiredAccess, shareMode, | 89 | _handle = ::CreateFileW(fs2us(path), desiredAccess, shareMode, |
90 | (LPSECURITY_ATTRIBUTES)NULL, creationDisposition, flagsAndAttributes, (HANDLE)NULL); | 90 | (LPSECURITY_ATTRIBUTES)NULL, creationDisposition, flagsAndAttributes, (HANDLE)NULL); |
91 | #ifdef WIN_LONG_PATH | 91 | #ifdef Z7_LONG_PATH |
92 | if (_handle == INVALID_HANDLE_VALUE && USE_SUPER_PATH) | 92 | if (_handle == INVALID_HANDLE_VALUE && USE_SUPER_PATH) |
93 | { | 93 | { |
94 | UString superPath; | 94 | UString superPath; |
@@ -101,7 +101,7 @@ bool CFileBase::Create(CFSTR path, DWORD desiredAccess, | |||
101 | 101 | ||
102 | /* | 102 | /* |
103 | #ifndef UNDER_CE | 103 | #ifndef UNDER_CE |
104 | #ifndef _SFX | 104 | #ifndef Z7_SFX |
105 | if (_handle == INVALID_HANDLE_VALUE) | 105 | if (_handle == INVALID_HANDLE_VALUE) |
106 | { | 106 | { |
107 | // it's debug hack to open symbolic links in Windows XP and WSL links in Windows 10 | 107 | // it's debug hack to open symbolic links in Windows XP and WSL links in Windows 10 |
@@ -149,7 +149,7 @@ bool CFileBase::Close() throw() | |||
149 | 149 | ||
150 | bool CFileBase::GetLength(UInt64 &length) const throw() | 150 | bool CFileBase::GetLength(UInt64 &length) const throw() |
151 | { | 151 | { |
152 | #ifdef SUPPORT_DEVICE_FILE | 152 | #ifdef Z7_DEVICE_FILE |
153 | if (IsDeviceFile && SizeDefined) | 153 | if (IsDeviceFile && SizeDefined) |
154 | { | 154 | { |
155 | length = Size; | 155 | length = Size; |
@@ -219,7 +219,7 @@ bool CFileBase::GetPosition(UInt64 &position) const throw() | |||
219 | 219 | ||
220 | bool CFileBase::Seek(Int64 distanceToMove, DWORD moveMethod, UInt64 &newPosition) const throw() | 220 | bool CFileBase::Seek(Int64 distanceToMove, DWORD moveMethod, UInt64 &newPosition) const throw() |
221 | { | 221 | { |
222 | #ifdef SUPPORT_DEVICE_FILE | 222 | #ifdef Z7_DEVICE_FILE |
223 | if (IsDeviceFile && SizeDefined && moveMethod == FILE_END) | 223 | if (IsDeviceFile && SizeDefined && moveMethod == FILE_END) |
224 | { | 224 | { |
225 | distanceToMove += Size; | 225 | distanceToMove += Size; |
@@ -262,12 +262,12 @@ bool CFileBase::SeekToEnd(UInt64 &newPosition) const throw() | |||
262 | 262 | ||
263 | // ---------- CInFile --------- | 263 | // ---------- CInFile --------- |
264 | 264 | ||
265 | #ifdef SUPPORT_DEVICE_FILE | 265 | #ifdef Z7_DEVICE_FILE |
266 | 266 | ||
267 | void CInFile::CorrectDeviceSize() | 267 | void CInFile::CorrectDeviceSize() |
268 | { | 268 | { |
269 | // maybe we must decrease kClusterSize to 1 << 12, if we want correct size at tail | 269 | // maybe we must decrease kClusterSize to 1 << 12, if we want correct size at tail |
270 | static const UInt32 kClusterSize = 1 << 14; | 270 | const UInt32 kClusterSize = 1 << 14; |
271 | UInt64 pos = Size & ~(UInt64)(kClusterSize - 1); | 271 | UInt64 pos = Size & ~(UInt64)(kClusterSize - 1); |
272 | UInt64 realNewPosition; | 272 | UInt64 realNewPosition; |
273 | if (!Seek(pos, realNewPosition)) | 273 | if (!Seek(pos, realNewPosition)) |
@@ -462,7 +462,7 @@ static const UInt32 kChunkSizeMax = (1 << 22); | |||
462 | bool CInFile::Read1(void *data, UInt32 size, UInt32 &processedSize) throw() | 462 | bool CInFile::Read1(void *data, UInt32 size, UInt32 &processedSize) throw() |
463 | { | 463 | { |
464 | DWORD processedLoc = 0; | 464 | DWORD processedLoc = 0; |
465 | bool res = BOOLToBool(::ReadFile(_handle, data, size, &processedLoc, NULL)); | 465 | const bool res = BOOLToBool(::ReadFile(_handle, data, size, &processedLoc, NULL)); |
466 | processedSize = (UInt32)processedLoc; | 466 | processedSize = (UInt32)processedLoc; |
467 | return res; | 467 | return res; |
468 | } | 468 | } |
@@ -480,7 +480,7 @@ bool CInFile::Read(void *data, UInt32 size, UInt32 &processedSize) throw() | |||
480 | do | 480 | do |
481 | { | 481 | { |
482 | UInt32 processedLoc = 0; | 482 | UInt32 processedLoc = 0; |
483 | bool res = ReadPart(data, size, processedLoc); | 483 | const bool res = ReadPart(data, size, processedLoc); |
484 | processedSize += processedLoc; | 484 | processedSize += processedLoc; |
485 | if (!res) | 485 | if (!res) |
486 | return false; | 486 | return false; |
@@ -551,7 +551,7 @@ bool COutFile::Write(const void *data, UInt32 size, UInt32 &processedSize) throw | |||
551 | do | 551 | do |
552 | { | 552 | { |
553 | UInt32 processedLoc = 0; | 553 | UInt32 processedLoc = 0; |
554 | bool res = WritePart(data, size, processedLoc); | 554 | const bool res = WritePart(data, size, processedLoc); |
555 | processedSize += processedLoc; | 555 | processedSize += processedLoc; |
556 | if (!res) | 556 | if (!res) |
557 | return false; | 557 | return false; |
@@ -628,14 +628,14 @@ bool SetDirTime(CFSTR path, const CFiTime *cTime, const CFiTime *aTime, const CF | |||
628 | 628 | ||
629 | namespace NIO { | 629 | namespace NIO { |
630 | 630 | ||
631 | bool CFileBase::OpenBinary(const char *name, int flags) | 631 | bool CFileBase::OpenBinary(const char *name, int flags, mode_t mode) |
632 | { | 632 | { |
633 | #ifdef O_BINARY | 633 | #ifdef O_BINARY |
634 | flags |= O_BINARY; | 634 | flags |= O_BINARY; |
635 | #endif | 635 | #endif |
636 | 636 | ||
637 | Close(); | 637 | Close(); |
638 | _handle = ::open(name, flags, 0666); | 638 | _handle = ::open(name, flags, mode); |
639 | return _handle != -1; | 639 | return _handle != -1; |
640 | 640 | ||
641 | /* | 641 | /* |
@@ -804,10 +804,10 @@ bool COutFile::Create(const char *name, bool createAlways) | |||
804 | if (createAlways) | 804 | if (createAlways) |
805 | { | 805 | { |
806 | Close(); | 806 | Close(); |
807 | _handle = ::creat(name, 0666); | 807 | _handle = ::creat(name, mode_for_Create); |
808 | return _handle != -1; | 808 | return _handle != -1; |
809 | } | 809 | } |
810 | return OpenBinary(name, O_CREAT | O_EXCL | O_WRONLY); | 810 | return OpenBinary(name, O_CREAT | O_EXCL | O_WRONLY, mode_for_Create); |
811 | } | 811 | } |
812 | 812 | ||
813 | bool COutFile::Open(const char *name, DWORD creationDisposition) | 813 | bool COutFile::Open(const char *name, DWORD creationDisposition) |
@@ -850,13 +850,13 @@ bool COutFile::SetLength(UInt64 length) throw() | |||
850 | return false; | 850 | return false; |
851 | } | 851 | } |
852 | // The value of the seek pointer shall not be modified by a call to ftruncate(). | 852 | // The value of the seek pointer shall not be modified by a call to ftruncate(). |
853 | int iret = ftruncate(_handle, len2); | 853 | const int iret = ftruncate(_handle, len2); |
854 | return (iret == 0); | 854 | return (iret == 0); |
855 | } | 855 | } |
856 | 856 | ||
857 | bool COutFile::Close() | 857 | bool COutFile::Close() |
858 | { | 858 | { |
859 | bool res = CFileBase::Close(); | 859 | const bool res = CFileBase::Close(); |
860 | if (!res) | 860 | if (!res) |
861 | return res; | 861 | return res; |
862 | if (CTime_defined || ATime_defined || MTime_defined) | 862 | if (CTime_defined || ATime_defined || MTime_defined) |