aboutsummaryrefslogtreecommitdiff
path: root/CPP/Windows/FileIO.h
diff options
context:
space:
mode:
authorIgor Pavlov <87184205+ip7z@users.noreply.github.com>2022-06-20 00:00:00 +0000
committerIgor Pavlov <87184205+ip7z@users.noreply.github.com>2023-12-17 13:35:20 +0500
commita3e1d227377188734b82f023f96f8e25dc40f3e6 (patch)
tree23cad8d47eb23d26ea727b4f7f4a65124f724065 /CPP/Windows/FileIO.h
parentf19f813537c7aea1c20749c914e756b54a9c3cf5 (diff)
download7zip-22.00.tar.gz
7zip-22.00.tar.bz2
7zip-22.00.zip
22.0022.00
Diffstat (limited to 'CPP/Windows/FileIO.h')
-rw-r--r--CPP/Windows/FileIO.h44
1 files changed, 37 insertions, 7 deletions
diff --git a/CPP/Windows/FileIO.h b/CPP/Windows/FileIO.h
index 22998eb..8050965 100644
--- a/CPP/Windows/FileIO.h
+++ b/CPP/Windows/FileIO.h
@@ -30,6 +30,8 @@
30#include "../Common/MyString.h" 30#include "../Common/MyString.h"
31#include "../Common/MyBuffer.h" 31#include "../Common/MyBuffer.h"
32 32
33#include "../Windows/TimeUtils.h"
34
33#include "Defs.h" 35#include "Defs.h"
34 36
35HRESULT GetLastError_noZero_HRESULT(); 37HRESULT GetLastError_noZero_HRESULT();
@@ -94,6 +96,12 @@ struct CReparseAttr
94 UString GetPath() const; 96 UString GetPath() const;
95}; 97};
96 98
99#ifdef _WIN32
100#define CFiInfo BY_HANDLE_FILE_INFORMATION
101#define ST_MTIME(st) (st).ftLastWriteTime
102#else
103#define CFiInfo stat
104#endif
97 105
98#ifdef _WIN32 106#ifdef _WIN32
99 107
@@ -142,6 +150,8 @@ public:
142 CFileBase(): _handle(INVALID_HANDLE_VALUE), PreserveATime(false) {}; 150 CFileBase(): _handle(INVALID_HANDLE_VALUE), PreserveATime(false) {};
143 ~CFileBase() { Close(); } 151 ~CFileBase() { Close(); }
144 152
153 HANDLE GetHandle() const { return _handle; }
154
145 bool Close() throw(); 155 bool Close() throw();
146 156
147 bool GetPosition(UInt64 &position) const throw(); 157 bool GetPosition(UInt64 &position) const throw();
@@ -213,6 +223,15 @@ public:
213 223
214 #ifndef UNDER_CE 224 #ifndef UNDER_CE
215 225
226 bool Open_for_ReadAttributes(CFSTR fileName)
227 {
228 return Create(fileName, FILE_READ_ATTRIBUTES,
229 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
230 OPEN_EXISTING,
231 FILE_FLAG_BACKUP_SEMANTICS);
232 // we must use (FILE_FLAG_BACKUP_SEMANTICS) to open handle of directory.
233 }
234
216 bool OpenReparse(CFSTR fileName) 235 bool OpenReparse(CFSTR fileName)
217 { 236 {
218 // 17.02 fix: to support Windows XP compatibility junctions: 237 // 17.02 fix: to support Windows XP compatibility junctions:
@@ -240,8 +259,8 @@ public:
240 bool Create(CFSTR fileName, bool createAlways); 259 bool Create(CFSTR fileName, bool createAlways);
241 bool CreateAlways(CFSTR fileName, DWORD flagsAndAttributes); 260 bool CreateAlways(CFSTR fileName, DWORD flagsAndAttributes);
242 261
243 bool SetTime(const FILETIME *cTime, const FILETIME *aTime, const FILETIME *mTime) throw(); 262 bool SetTime(const CFiTime *cTime, const CFiTime *aTime, const CFiTime *mTime) throw();
244 bool SetMTime(const FILETIME *mTime) throw(); 263 bool SetMTime(const CFiTime *mTime) throw();
245 bool WritePart(const void *data, UInt32 size, UInt32 &processedSize) throw(); 264 bool WritePart(const void *data, UInt32 size, UInt32 &processedSize) throw();
246 bool Write(const void *data, UInt32 size, UInt32 &processedSize) throw(); 265 bool Write(const void *data, UInt32 size, UInt32 &processedSize) throw();
247 bool WriteFull(const void *data, size_t size) throw(); 266 bool WriteFull(const void *data, size_t size) throw();
@@ -270,6 +289,12 @@ class CFileBase
270protected: 289protected:
271 int _handle; 290 int _handle;
272 291
292 /*
293 bool IsDeviceFile;
294 bool SizeDefined;
295 UInt64 Size; // it can be larger than real available size
296 */
297
273 bool OpenBinary(const char *name, int flags); 298 bool OpenBinary(const char *name, int flags);
274public: 299public:
275 bool PreserveATime; 300 bool PreserveATime;
@@ -283,6 +308,11 @@ public:
283 off_t seekToCur() const throw(); 308 off_t seekToCur() const throw();
284 // bool SeekToBegin() throw(); 309 // bool SeekToBegin() throw();
285 int my_fstat(struct stat *st) const { return fstat(_handle, st); } 310 int my_fstat(struct stat *st) const { return fstat(_handle, st); }
311 /*
312 int my_ioctl_BLKGETSIZE64(unsigned long long *val);
313 int GetDeviceSize_InBytes(UInt64 &size);
314 void CalcDeviceSize(CFSTR s);
315 */
286}; 316};
287 317
288class CInFile: public CFileBase 318class CInFile: public CFileBase
@@ -301,9 +331,9 @@ class COutFile: public CFileBase
301 bool ATime_defined; 331 bool ATime_defined;
302 bool MTime_defined; 332 bool MTime_defined;
303 333
304 FILETIME CTime; 334 CFiTime CTime;
305 FILETIME ATime; 335 CFiTime ATime;
306 FILETIME MTime; 336 CFiTime MTime;
307 337
308 AString Path; 338 AString Path;
309 ssize_t write_part(const void *data, size_t size) throw(); 339 ssize_t write_part(const void *data, size_t size) throw();
@@ -333,8 +363,8 @@ public:
333 { 363 {
334 return SetLength(length); 364 return SetLength(length);
335 } 365 }
336 bool SetTime(const FILETIME *cTime, const FILETIME *aTime, const FILETIME *mTime) throw(); 366 bool SetTime(const CFiTime *cTime, const CFiTime *aTime, const CFiTime *mTime) throw();
337 bool SetMTime(const FILETIME *mTime) throw(); 367 bool SetMTime(const CFiTime *mTime) throw();
338}; 368};
339 369
340} 370}