aboutsummaryrefslogtreecommitdiff
path: root/CPP/Windows/FileIO.h
diff options
context:
space:
mode:
Diffstat (limited to 'CPP/Windows/FileIO.h')
-rw-r--r--CPP/Windows/FileIO.h76
1 files changed, 67 insertions, 9 deletions
diff --git a/CPP/Windows/FileIO.h b/CPP/Windows/FileIO.h
index 03e061a..6ba40eb 100644
--- a/CPP/Windows/FileIO.h
+++ b/CPP/Windows/FileIO.h
@@ -141,13 +141,24 @@ public:
141 141
142public: 142public:
143 bool PreserveATime; 143 bool PreserveATime;
144 #ifdef Z7_DEVICE_FILE 144#if 0
145 bool IsStdStream;
146 bool IsStdPipeStream;
147#endif
148#ifdef Z7_DEVICE_FILE
145 bool IsDeviceFile; 149 bool IsDeviceFile;
146 bool SizeDefined; 150 bool SizeDefined;
147 UInt64 Size; // it can be larger than real available size 151 UInt64 Size; // it can be larger than real available size
148 #endif 152#endif
149 153
150 CFileBase(): _handle(INVALID_HANDLE_VALUE), PreserveATime(false) {} 154 CFileBase():
155 _handle(INVALID_HANDLE_VALUE),
156 PreserveATime(false)
157#if 0
158 , IsStdStream(false),
159 , IsStdPipeStream(false)
160#endif
161 {}
151 ~CFileBase() { Close(); } 162 ~CFileBase() { Close(); }
152 163
153 HANDLE GetHandle() const { return _handle; } 164 HANDLE GetHandle() const { return _handle; }
@@ -223,6 +234,20 @@ public:
223 bool OpenShared(CFSTR fileName, bool shareForWrite); 234 bool OpenShared(CFSTR fileName, bool shareForWrite);
224 bool Open(CFSTR fileName); 235 bool Open(CFSTR fileName);
225 236
237#if 0
238 bool AttachStdIn()
239 {
240 IsDeviceFile = false;
241 const HANDLE h = GetStdHandle(STD_INPUT_HANDLE);
242 if (h == INVALID_HANDLE_VALUE || !h)
243 return false;
244 IsStdStream = true;
245 IsStdPipeStream = true;
246 _handle = h;
247 return true;
248 }
249#endif
250
226 #ifndef UNDER_CE 251 #ifndef UNDER_CE
227 252
228 bool Open_for_ReadAttributes(CFSTR fileName) 253 bool Open_for_ReadAttributes(CFSTR fileName)
@@ -263,11 +288,21 @@ public:
263 288
264class COutFile: public CFileBase 289class COutFile: public CFileBase
265{ 290{
291 bool Open_Disposition(CFSTR fileName, DWORD creationDisposition);
266public: 292public:
267 bool Open(CFSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes); 293 bool Open(CFSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
268 bool Open(CFSTR fileName, DWORD creationDisposition); 294 bool Open_EXISTING(CFSTR fileName)
269 bool Create(CFSTR fileName, bool createAlways); 295 { return Open_Disposition(fileName, OPEN_EXISTING); }
270 bool CreateAlways(CFSTR fileName, DWORD flagsAndAttributes); 296 bool Create_ALWAYS_or_Open_ALWAYS(CFSTR fileName, bool createAlways)
297 { return Open_Disposition(fileName, createAlways ? CREATE_ALWAYS : OPEN_ALWAYS); }
298 bool Create_ALWAYS_or_NEW(CFSTR fileName, bool createAlways)
299 { return Open_Disposition(fileName, createAlways ? CREATE_ALWAYS : CREATE_NEW); }
300 bool Create_ALWAYS(CFSTR fileName)
301 { return Open_Disposition(fileName, CREATE_ALWAYS); }
302 bool Create_NEW(CFSTR fileName)
303 { return Open_Disposition(fileName, CREATE_NEW); }
304
305 bool Create_ALWAYS_with_Attribs(CFSTR fileName, DWORD flagsAndAttributes);
271 306
272 bool SetTime(const CFiTime *cTime, const CFiTime *aTime, const CFiTime *mTime) throw(); 307 bool SetTime(const CFiTime *cTime, const CFiTime *aTime, const CFiTime *mTime) throw();
273 bool SetMTime(const CFiTime *mTime) throw(); 308 bool SetMTime(const CFiTime *mTime) throw();
@@ -308,8 +343,15 @@ protected:
308 bool OpenBinary(const char *name, int flags, mode_t mode = 0666); 343 bool OpenBinary(const char *name, int flags, mode_t mode = 0666);
309public: 344public:
310 bool PreserveATime; 345 bool PreserveATime;
346#if 0
347 bool IsStdStream;
348#endif
311 349
312 CFileBase(): _handle(-1), PreserveATime(false) {} 350 CFileBase(): _handle(-1), PreserveATime(false)
351#if 0
352 , IsStdStream(false)
353#endif
354 {}
313 ~CFileBase() { Close(); } 355 ~CFileBase() { Close(); }
314 // void Detach() { _handle = -1; } 356 // void Detach() { _handle = -1; }
315 bool Close(); 357 bool Close();
@@ -331,6 +373,15 @@ class CInFile: public CFileBase
331public: 373public:
332 bool Open(const char *name); 374 bool Open(const char *name);
333 bool OpenShared(const char *name, bool shareForWrite); 375 bool OpenShared(const char *name, bool shareForWrite);
376#if 0
377 bool AttachStdIn()
378 {
379 _handle = GetStdHandle(STD_INPUT_HANDLE);
380 if (_handle == INVALID_HANDLE_VALUE || !_handle)
381 return false;
382 IsStdStream = true;
383 }
384#endif
334 ssize_t read_part(void *data, size_t size) throw(); 385 ssize_t read_part(void *data, size_t size) throw();
335 // ssize_t read_full(void *data, size_t size, size_t &processed); 386 // ssize_t read_full(void *data, size_t size, size_t &processed);
336 bool ReadFull(void *data, size_t size, size_t &processedSize) throw(); 387 bool ReadFull(void *data, size_t size, size_t &processedSize) throw();
@@ -347,6 +398,7 @@ class COutFile: public CFileBase
347 398
348 AString Path; 399 AString Path;
349 ssize_t write_part(const void *data, size_t size) throw(); 400 ssize_t write_part(const void *data, size_t size) throw();
401 bool OpenBinary_forWrite_oflag(const char *name, int oflag);
350public: 402public:
351 mode_t mode_for_Create; 403 mode_t mode_for_Create;
352 404
@@ -358,8 +410,14 @@ public:
358 {} 410 {}
359 411
360 bool Close(); 412 bool Close();
361 bool Create(const char *name, bool createAlways); 413
362 bool Open(const char *name, DWORD creationDisposition); 414 bool Open_EXISTING(CFSTR fileName);
415 bool Create_ALWAYS_or_Open_ALWAYS(CFSTR fileName, bool createAlways);
416 bool Create_ALWAYS(CFSTR fileName);
417 bool Create_NEW(CFSTR fileName);
418 // bool Create_ALWAYS_or_NEW(CFSTR fileName, bool createAlways);
419 // bool Open_Disposition(const char *name, DWORD creationDisposition);
420
363 ssize_t write_full(const void *data, size_t size, size_t &processed) throw(); 421 ssize_t write_full(const void *data, size_t size, size_t &processed) throw();
364 422
365 bool WriteFull(const void *data, size_t size) throw() 423 bool WriteFull(const void *data, size_t size) throw()