1370b324cSopenharmony_ci// Windows/FileIO.h 2370b324cSopenharmony_ci 3370b324cSopenharmony_ci#ifndef ZIP7_INC_WINDOWS_FILE_IO_H 4370b324cSopenharmony_ci#define ZIP7_INC_WINDOWS_FILE_IO_H 5370b324cSopenharmony_ci 6370b324cSopenharmony_ci#include "../Common/MyWindows.h" 7370b324cSopenharmony_ci 8370b324cSopenharmony_ci#define Z7_WIN_IO_REPARSE_TAG_MOUNT_POINT (0xA0000003L) 9370b324cSopenharmony_ci#define Z7_WIN_IO_REPARSE_TAG_SYMLINK (0xA000000CL) 10370b324cSopenharmony_ci#define Z7_WIN_IO_REPARSE_TAG_LX_SYMLINK (0xA000001DL) 11370b324cSopenharmony_ci 12370b324cSopenharmony_ci#define Z7_WIN_SYMLINK_FLAG_RELATIVE 1 13370b324cSopenharmony_ci 14370b324cSopenharmony_ci// what the meaning of that FLAG or field (2)? 15370b324cSopenharmony_ci#define Z7_WIN_LX_SYMLINK_FLAG 2 16370b324cSopenharmony_ci 17370b324cSopenharmony_ci#ifdef _WIN32 18370b324cSopenharmony_ci 19370b324cSopenharmony_ci#if defined(_WIN32) && !defined(UNDER_CE) 20370b324cSopenharmony_ci#include <winioctl.h> 21370b324cSopenharmony_ci#endif 22370b324cSopenharmony_ci 23370b324cSopenharmony_ci#else 24370b324cSopenharmony_ci 25370b324cSopenharmony_ci#include <sys/types.h> 26370b324cSopenharmony_ci#include <sys/stat.h> 27370b324cSopenharmony_ci 28370b324cSopenharmony_ci#endif 29370b324cSopenharmony_ci 30370b324cSopenharmony_ci#include "../Common/MyString.h" 31370b324cSopenharmony_ci#include "../Common/MyBuffer.h" 32370b324cSopenharmony_ci 33370b324cSopenharmony_ci#include "../Windows/TimeUtils.h" 34370b324cSopenharmony_ci 35370b324cSopenharmony_ci#include "Defs.h" 36370b324cSopenharmony_ci 37370b324cSopenharmony_ciHRESULT GetLastError_noZero_HRESULT(); 38370b324cSopenharmony_ci 39370b324cSopenharmony_ci#define my_FSCTL_SET_REPARSE_POINT CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 41, METHOD_BUFFERED, FILE_SPECIAL_ACCESS) // REPARSE_DATA_BUFFER 40370b324cSopenharmony_ci#define my_FSCTL_GET_REPARSE_POINT CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 42, METHOD_BUFFERED, FILE_ANY_ACCESS) // REPARSE_DATA_BUFFER 41370b324cSopenharmony_ci#define my_FSCTL_DELETE_REPARSE_POINT CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 43, METHOD_BUFFERED, FILE_SPECIAL_ACCESS) // REPARSE_DATA_BUFFER 42370b324cSopenharmony_ci 43370b324cSopenharmony_cinamespace NWindows { 44370b324cSopenharmony_cinamespace NFile { 45370b324cSopenharmony_ci 46370b324cSopenharmony_ci#if defined(_WIN32) && !defined(UNDER_CE) 47370b324cSopenharmony_cibool FillLinkData(CByteBuffer &dest, const wchar_t *path, bool isSymLink, bool isWSL); 48370b324cSopenharmony_ci#endif 49370b324cSopenharmony_ci 50370b324cSopenharmony_cistruct CReparseShortInfo 51370b324cSopenharmony_ci{ 52370b324cSopenharmony_ci unsigned Offset; 53370b324cSopenharmony_ci unsigned Size; 54370b324cSopenharmony_ci 55370b324cSopenharmony_ci bool Parse(const Byte *p, size_t size); 56370b324cSopenharmony_ci}; 57370b324cSopenharmony_ci 58370b324cSopenharmony_cistruct CReparseAttr 59370b324cSopenharmony_ci{ 60370b324cSopenharmony_ci UInt32 Tag; 61370b324cSopenharmony_ci UInt32 Flags; 62370b324cSopenharmony_ci UString SubsName; 63370b324cSopenharmony_ci UString PrintName; 64370b324cSopenharmony_ci 65370b324cSopenharmony_ci AString WslName; 66370b324cSopenharmony_ci 67370b324cSopenharmony_ci bool HeaderError; 68370b324cSopenharmony_ci bool TagIsUnknown; 69370b324cSopenharmony_ci bool MinorError; 70370b324cSopenharmony_ci DWORD ErrorCode; 71370b324cSopenharmony_ci 72370b324cSopenharmony_ci CReparseAttr(): Tag(0), Flags(0) {} 73370b324cSopenharmony_ci 74370b324cSopenharmony_ci // Parse() 75370b324cSopenharmony_ci // returns (true) and (ErrorCode = 0), if (it'a correct known link) 76370b324cSopenharmony_ci // returns (false) and (ErrorCode = ERROR_REPARSE_TAG_INVALID), if unknown tag 77370b324cSopenharmony_ci bool Parse(const Byte *p, size_t size); 78370b324cSopenharmony_ci 79370b324cSopenharmony_ci bool IsMountPoint() const { return Tag == Z7_WIN_IO_REPARSE_TAG_MOUNT_POINT; } // it's Junction 80370b324cSopenharmony_ci bool IsSymLink_Win() const { return Tag == Z7_WIN_IO_REPARSE_TAG_SYMLINK; } 81370b324cSopenharmony_ci bool IsSymLink_WSL() const { return Tag == Z7_WIN_IO_REPARSE_TAG_LX_SYMLINK; } 82370b324cSopenharmony_ci 83370b324cSopenharmony_ci bool IsRelative_Win() const { return Flags == Z7_WIN_SYMLINK_FLAG_RELATIVE; } 84370b324cSopenharmony_ci 85370b324cSopenharmony_ci bool IsRelative_WSL() const 86370b324cSopenharmony_ci { 87370b324cSopenharmony_ci if (WslName.IsEmpty()) 88370b324cSopenharmony_ci return true; 89370b324cSopenharmony_ci char c = WslName[0]; 90370b324cSopenharmony_ci return !IS_PATH_SEPAR(c); 91370b324cSopenharmony_ci } 92370b324cSopenharmony_ci 93370b324cSopenharmony_ci // bool IsVolume() const; 94370b324cSopenharmony_ci 95370b324cSopenharmony_ci bool IsOkNamePair() const; 96370b324cSopenharmony_ci UString GetPath() const; 97370b324cSopenharmony_ci}; 98370b324cSopenharmony_ci 99370b324cSopenharmony_ci#ifdef _WIN32 100370b324cSopenharmony_ci#define CFiInfo BY_HANDLE_FILE_INFORMATION 101370b324cSopenharmony_ci#define ST_MTIME(st) (st).ftLastWriteTime 102370b324cSopenharmony_ci#else 103370b324cSopenharmony_ci#define CFiInfo stat 104370b324cSopenharmony_ci#endif 105370b324cSopenharmony_ci 106370b324cSopenharmony_ci#ifdef _WIN32 107370b324cSopenharmony_ci 108370b324cSopenharmony_cinamespace NIO { 109370b324cSopenharmony_ci 110370b324cSopenharmony_cibool GetReparseData(CFSTR path, CByteBuffer &reparseData, BY_HANDLE_FILE_INFORMATION *fileInfo = NULL); 111370b324cSopenharmony_cibool SetReparseData(CFSTR path, bool isDir, const void *data, DWORD size); 112370b324cSopenharmony_cibool DeleteReparseData(CFSTR path); 113370b324cSopenharmony_ci 114370b324cSopenharmony_ciclass CFileBase MY_UNCOPYABLE 115370b324cSopenharmony_ci{ 116370b324cSopenharmony_ciprotected: 117370b324cSopenharmony_ci HANDLE _handle; 118370b324cSopenharmony_ci 119370b324cSopenharmony_ci bool Create(CFSTR path, DWORD desiredAccess, 120370b324cSopenharmony_ci DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes); 121370b324cSopenharmony_ci 122370b324cSopenharmony_cipublic: 123370b324cSopenharmony_ci 124370b324cSopenharmony_ci bool DeviceIoControl(DWORD controlCode, LPVOID inBuffer, DWORD inSize, 125370b324cSopenharmony_ci LPVOID outBuffer, DWORD outSize, LPDWORD bytesReturned, LPOVERLAPPED overlapped = NULL) const 126370b324cSopenharmony_ci { 127370b324cSopenharmony_ci return BOOLToBool(::DeviceIoControl(_handle, controlCode, inBuffer, inSize, 128370b324cSopenharmony_ci outBuffer, outSize, bytesReturned, overlapped)); 129370b324cSopenharmony_ci } 130370b324cSopenharmony_ci 131370b324cSopenharmony_ci bool DeviceIoControlOut(DWORD controlCode, LPVOID outBuffer, DWORD outSize, LPDWORD bytesReturned) const 132370b324cSopenharmony_ci { 133370b324cSopenharmony_ci return DeviceIoControl(controlCode, NULL, 0, outBuffer, outSize, bytesReturned); 134370b324cSopenharmony_ci } 135370b324cSopenharmony_ci 136370b324cSopenharmony_ci bool DeviceIoControlOut(DWORD controlCode, LPVOID outBuffer, DWORD outSize) const 137370b324cSopenharmony_ci { 138370b324cSopenharmony_ci DWORD bytesReturned; 139370b324cSopenharmony_ci return DeviceIoControlOut(controlCode, outBuffer, outSize, &bytesReturned); 140370b324cSopenharmony_ci } 141370b324cSopenharmony_ci 142370b324cSopenharmony_cipublic: 143370b324cSopenharmony_ci bool PreserveATime; 144370b324cSopenharmony_ci #ifdef Z7_DEVICE_FILE 145370b324cSopenharmony_ci bool IsDeviceFile; 146370b324cSopenharmony_ci bool SizeDefined; 147370b324cSopenharmony_ci UInt64 Size; // it can be larger than real available size 148370b324cSopenharmony_ci #endif 149370b324cSopenharmony_ci 150370b324cSopenharmony_ci CFileBase(): _handle(INVALID_HANDLE_VALUE), PreserveATime(false) {} 151370b324cSopenharmony_ci ~CFileBase() { Close(); } 152370b324cSopenharmony_ci 153370b324cSopenharmony_ci HANDLE GetHandle() const { return _handle; } 154370b324cSopenharmony_ci 155370b324cSopenharmony_ci // void Detach() { _handle = INVALID_HANDLE_VALUE; } 156370b324cSopenharmony_ci 157370b324cSopenharmony_ci bool Close() throw(); 158370b324cSopenharmony_ci 159370b324cSopenharmony_ci bool GetPosition(UInt64 &position) const throw(); 160370b324cSopenharmony_ci bool GetLength(UInt64 &length) const throw(); 161370b324cSopenharmony_ci 162370b324cSopenharmony_ci bool Seek(Int64 distanceToMove, DWORD moveMethod, UInt64 &newPosition) const throw(); 163370b324cSopenharmony_ci bool Seek(UInt64 position, UInt64 &newPosition) const throw(); 164370b324cSopenharmony_ci bool SeekToBegin() const throw(); 165370b324cSopenharmony_ci bool SeekToEnd(UInt64 &newPosition) const throw(); 166370b324cSopenharmony_ci 167370b324cSopenharmony_ci bool GetFileInformation(BY_HANDLE_FILE_INFORMATION *info) const 168370b324cSopenharmony_ci { return BOOLToBool(GetFileInformationByHandle(_handle, info)); } 169370b324cSopenharmony_ci 170370b324cSopenharmony_ci static bool GetFileInformation(CFSTR path, BY_HANDLE_FILE_INFORMATION *info) 171370b324cSopenharmony_ci { 172370b324cSopenharmony_ci // probably it can work for complex paths: unsupported by another things 173370b324cSopenharmony_ci NIO::CFileBase file; 174370b324cSopenharmony_ci if (!file.Create(path, 0, FILE_SHARE_READ, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS)) 175370b324cSopenharmony_ci return false; 176370b324cSopenharmony_ci return file.GetFileInformation(info); 177370b324cSopenharmony_ci } 178370b324cSopenharmony_ci}; 179370b324cSopenharmony_ci 180370b324cSopenharmony_ci#ifndef UNDER_CE 181370b324cSopenharmony_ci#define IOCTL_CDROM_BASE FILE_DEVICE_CD_ROM 182370b324cSopenharmony_ci#define IOCTL_CDROM_GET_DRIVE_GEOMETRY CTL_CODE(IOCTL_CDROM_BASE, 0x0013, METHOD_BUFFERED, FILE_READ_ACCESS) 183370b324cSopenharmony_ci// #define IOCTL_CDROM_MEDIA_REMOVAL CTL_CODE(IOCTL_CDROM_BASE, 0x0201, METHOD_BUFFERED, FILE_READ_ACCESS) 184370b324cSopenharmony_ci 185370b324cSopenharmony_ci// IOCTL_DISK_GET_DRIVE_GEOMETRY_EX works since WinXP 186370b324cSopenharmony_ci#define my_IOCTL_DISK_GET_DRIVE_GEOMETRY_EX CTL_CODE(IOCTL_DISK_BASE, 0x0028, METHOD_BUFFERED, FILE_ANY_ACCESS) 187370b324cSopenharmony_ci 188370b324cSopenharmony_cistruct my_DISK_GEOMETRY_EX 189370b324cSopenharmony_ci{ 190370b324cSopenharmony_ci DISK_GEOMETRY Geometry; 191370b324cSopenharmony_ci LARGE_INTEGER DiskSize; 192370b324cSopenharmony_ci BYTE Data[1]; 193370b324cSopenharmony_ci}; 194370b324cSopenharmony_ci#endif 195370b324cSopenharmony_ci 196370b324cSopenharmony_ciclass CInFile: public CFileBase 197370b324cSopenharmony_ci{ 198370b324cSopenharmony_ci #ifdef Z7_DEVICE_FILE 199370b324cSopenharmony_ci 200370b324cSopenharmony_ci #ifndef UNDER_CE 201370b324cSopenharmony_ci 202370b324cSopenharmony_ci bool GetGeometry(DISK_GEOMETRY *res) const 203370b324cSopenharmony_ci { return DeviceIoControlOut(IOCTL_DISK_GET_DRIVE_GEOMETRY, res, sizeof(*res)); } 204370b324cSopenharmony_ci 205370b324cSopenharmony_ci bool GetGeometryEx(my_DISK_GEOMETRY_EX *res) const 206370b324cSopenharmony_ci { return DeviceIoControlOut(my_IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, res, sizeof(*res)); } 207370b324cSopenharmony_ci 208370b324cSopenharmony_ci bool GetCdRomGeometry(DISK_GEOMETRY *res) const 209370b324cSopenharmony_ci { return DeviceIoControlOut(IOCTL_CDROM_GET_DRIVE_GEOMETRY, res, sizeof(*res)); } 210370b324cSopenharmony_ci 211370b324cSopenharmony_ci bool GetPartitionInfo(PARTITION_INFORMATION *res) 212370b324cSopenharmony_ci { return DeviceIoControlOut(IOCTL_DISK_GET_PARTITION_INFO, LPVOID(res), sizeof(*res)); } 213370b324cSopenharmony_ci 214370b324cSopenharmony_ci #endif 215370b324cSopenharmony_ci 216370b324cSopenharmony_ci void CorrectDeviceSize(); 217370b324cSopenharmony_ci void CalcDeviceSize(CFSTR name); 218370b324cSopenharmony_ci 219370b324cSopenharmony_ci #endif 220370b324cSopenharmony_ci 221370b324cSopenharmony_cipublic: 222370b324cSopenharmony_ci bool Open(CFSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes); 223370b324cSopenharmony_ci bool OpenShared(CFSTR fileName, bool shareForWrite); 224370b324cSopenharmony_ci bool Open(CFSTR fileName); 225370b324cSopenharmony_ci 226370b324cSopenharmony_ci #ifndef UNDER_CE 227370b324cSopenharmony_ci 228370b324cSopenharmony_ci bool Open_for_ReadAttributes(CFSTR fileName) 229370b324cSopenharmony_ci { 230370b324cSopenharmony_ci return Create(fileName, FILE_READ_ATTRIBUTES, 231370b324cSopenharmony_ci FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, 232370b324cSopenharmony_ci OPEN_EXISTING, 233370b324cSopenharmony_ci FILE_FLAG_BACKUP_SEMANTICS); 234370b324cSopenharmony_ci // we must use (FILE_FLAG_BACKUP_SEMANTICS) to open handle of directory. 235370b324cSopenharmony_ci } 236370b324cSopenharmony_ci 237370b324cSopenharmony_ci bool Open_for_FileRenameInformation(CFSTR fileName) 238370b324cSopenharmony_ci { 239370b324cSopenharmony_ci return Create(fileName, DELETE | SYNCHRONIZE | GENERIC_READ, 240370b324cSopenharmony_ci FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, 241370b324cSopenharmony_ci OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL); 242370b324cSopenharmony_ci // we must use (FILE_FLAG_BACKUP_SEMANTICS) to open handle of directory. 243370b324cSopenharmony_ci } 244370b324cSopenharmony_ci 245370b324cSopenharmony_ci bool OpenReparse(CFSTR fileName) 246370b324cSopenharmony_ci { 247370b324cSopenharmony_ci // 17.02 fix: to support Windows XP compatibility junctions: 248370b324cSopenharmony_ci // we use Create() with (desiredAccess = 0) instead of Open() with GENERIC_READ 249370b324cSopenharmony_ci return 250370b324cSopenharmony_ci Create(fileName, 0, 251370b324cSopenharmony_ci // Open(fileName, 252370b324cSopenharmony_ci FILE_SHARE_READ, OPEN_EXISTING, 253370b324cSopenharmony_ci FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS); 254370b324cSopenharmony_ci } 255370b324cSopenharmony_ci 256370b324cSopenharmony_ci #endif 257370b324cSopenharmony_ci 258370b324cSopenharmony_ci bool Read1(void *data, UInt32 size, UInt32 &processedSize) throw(); 259370b324cSopenharmony_ci bool ReadPart(void *data, UInt32 size, UInt32 &processedSize) throw(); 260370b324cSopenharmony_ci bool Read(void *data, UInt32 size, UInt32 &processedSize) throw(); 261370b324cSopenharmony_ci bool ReadFull(void *data, size_t size, size_t &processedSize) throw(); 262370b324cSopenharmony_ci}; 263370b324cSopenharmony_ci 264370b324cSopenharmony_ciclass COutFile: public CFileBase 265370b324cSopenharmony_ci{ 266370b324cSopenharmony_cipublic: 267370b324cSopenharmony_ci bool Open(CFSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes); 268370b324cSopenharmony_ci bool Open(CFSTR fileName, DWORD creationDisposition); 269370b324cSopenharmony_ci bool Create(CFSTR fileName, bool createAlways); 270370b324cSopenharmony_ci bool CreateAlways(CFSTR fileName, DWORD flagsAndAttributes); 271370b324cSopenharmony_ci 272370b324cSopenharmony_ci bool SetTime(const CFiTime *cTime, const CFiTime *aTime, const CFiTime *mTime) throw(); 273370b324cSopenharmony_ci bool SetMTime(const CFiTime *mTime) throw(); 274370b324cSopenharmony_ci bool WritePart(const void *data, UInt32 size, UInt32 &processedSize) throw(); 275370b324cSopenharmony_ci bool Write(const void *data, UInt32 size, UInt32 &processedSize) throw(); 276370b324cSopenharmony_ci bool WriteFull(const void *data, size_t size) throw(); 277370b324cSopenharmony_ci bool SetEndOfFile() throw(); 278370b324cSopenharmony_ci bool SetLength(UInt64 length) throw(); 279370b324cSopenharmony_ci bool SetLength_KeepPosition(UInt64 length) throw(); 280370b324cSopenharmony_ci}; 281370b324cSopenharmony_ci 282370b324cSopenharmony_ci} 283370b324cSopenharmony_ci 284370b324cSopenharmony_ci 285370b324cSopenharmony_ci#else // _WIN32 286370b324cSopenharmony_ci 287370b324cSopenharmony_cinamespace NIO { 288370b324cSopenharmony_ci 289370b324cSopenharmony_cibool GetReparseData(CFSTR path, CByteBuffer &reparseData); 290370b324cSopenharmony_ci// bool SetReparseData(CFSTR path, bool isDir, const void *data, DWORD size); 291370b324cSopenharmony_ci 292370b324cSopenharmony_ci// parameters are in reverse order of symlink() function !!! 293370b324cSopenharmony_cibool SetSymLink(CFSTR from, CFSTR to); 294370b324cSopenharmony_cibool SetSymLink_UString(CFSTR from, const UString &to); 295370b324cSopenharmony_ci 296370b324cSopenharmony_ci 297370b324cSopenharmony_ciclass CFileBase 298370b324cSopenharmony_ci{ 299370b324cSopenharmony_ciprotected: 300370b324cSopenharmony_ci int _handle; 301370b324cSopenharmony_ci 302370b324cSopenharmony_ci /* 303370b324cSopenharmony_ci bool IsDeviceFile; 304370b324cSopenharmony_ci bool SizeDefined; 305370b324cSopenharmony_ci UInt64 Size; // it can be larger than real available size 306370b324cSopenharmony_ci */ 307370b324cSopenharmony_ci 308370b324cSopenharmony_ci bool OpenBinary(const char *name, int flags, mode_t mode = 0666); 309370b324cSopenharmony_cipublic: 310370b324cSopenharmony_ci bool PreserveATime; 311370b324cSopenharmony_ci 312370b324cSopenharmony_ci CFileBase(): _handle(-1), PreserveATime(false) {} 313370b324cSopenharmony_ci ~CFileBase() { Close(); } 314370b324cSopenharmony_ci // void Detach() { _handle = -1; } 315370b324cSopenharmony_ci bool Close(); 316370b324cSopenharmony_ci bool GetLength(UInt64 &length) const; 317370b324cSopenharmony_ci off_t seek(off_t distanceToMove, int moveMethod) const; 318370b324cSopenharmony_ci off_t seekToBegin() const throw(); 319370b324cSopenharmony_ci off_t seekToCur() const throw(); 320370b324cSopenharmony_ci // bool SeekToBegin() throw(); 321370b324cSopenharmony_ci int my_fstat(struct stat *st) const { return fstat(_handle, st); } 322370b324cSopenharmony_ci /* 323370b324cSopenharmony_ci int my_ioctl_BLKGETSIZE64(unsigned long long *val); 324370b324cSopenharmony_ci int GetDeviceSize_InBytes(UInt64 &size); 325370b324cSopenharmony_ci void CalcDeviceSize(CFSTR s); 326370b324cSopenharmony_ci */ 327370b324cSopenharmony_ci}; 328370b324cSopenharmony_ci 329370b324cSopenharmony_ciclass CInFile: public CFileBase 330370b324cSopenharmony_ci{ 331370b324cSopenharmony_cipublic: 332370b324cSopenharmony_ci bool Open(const char *name); 333370b324cSopenharmony_ci bool OpenShared(const char *name, bool shareForWrite); 334370b324cSopenharmony_ci ssize_t read_part(void *data, size_t size) throw(); 335370b324cSopenharmony_ci // ssize_t read_full(void *data, size_t size, size_t &processed); 336370b324cSopenharmony_ci bool ReadFull(void *data, size_t size, size_t &processedSize) throw(); 337370b324cSopenharmony_ci}; 338370b324cSopenharmony_ci 339370b324cSopenharmony_ciclass COutFile: public CFileBase 340370b324cSopenharmony_ci{ 341370b324cSopenharmony_ci bool CTime_defined; 342370b324cSopenharmony_ci bool ATime_defined; 343370b324cSopenharmony_ci bool MTime_defined; 344370b324cSopenharmony_ci CFiTime CTime; 345370b324cSopenharmony_ci CFiTime ATime; 346370b324cSopenharmony_ci CFiTime MTime; 347370b324cSopenharmony_ci 348370b324cSopenharmony_ci AString Path; 349370b324cSopenharmony_ci ssize_t write_part(const void *data, size_t size) throw(); 350370b324cSopenharmony_cipublic: 351370b324cSopenharmony_ci mode_t mode_for_Create; 352370b324cSopenharmony_ci 353370b324cSopenharmony_ci COutFile(): 354370b324cSopenharmony_ci CTime_defined(false), 355370b324cSopenharmony_ci ATime_defined(false), 356370b324cSopenharmony_ci MTime_defined(false), 357370b324cSopenharmony_ci mode_for_Create(0666) 358370b324cSopenharmony_ci {} 359370b324cSopenharmony_ci 360370b324cSopenharmony_ci bool Close(); 361370b324cSopenharmony_ci bool Create(const char *name, bool createAlways); 362370b324cSopenharmony_ci bool Open(const char *name, DWORD creationDisposition); 363370b324cSopenharmony_ci ssize_t write_full(const void *data, size_t size, size_t &processed) throw(); 364370b324cSopenharmony_ci 365370b324cSopenharmony_ci bool WriteFull(const void *data, size_t size) throw() 366370b324cSopenharmony_ci { 367370b324cSopenharmony_ci size_t processed; 368370b324cSopenharmony_ci ssize_t res = write_full(data, size, processed); 369370b324cSopenharmony_ci if (res == -1) 370370b324cSopenharmony_ci return false; 371370b324cSopenharmony_ci return processed == size; 372370b324cSopenharmony_ci } 373370b324cSopenharmony_ci 374370b324cSopenharmony_ci bool SetLength(UInt64 length) throw(); 375370b324cSopenharmony_ci bool SetLength_KeepPosition(UInt64 length) throw() 376370b324cSopenharmony_ci { 377370b324cSopenharmony_ci return SetLength(length); 378370b324cSopenharmony_ci } 379370b324cSopenharmony_ci bool SetTime(const CFiTime *cTime, const CFiTime *aTime, const CFiTime *mTime) throw(); 380370b324cSopenharmony_ci bool SetMTime(const CFiTime *mTime) throw(); 381370b324cSopenharmony_ci}; 382370b324cSopenharmony_ci 383370b324cSopenharmony_ci} 384370b324cSopenharmony_ci 385370b324cSopenharmony_ci#endif // _WIN32 386370b324cSopenharmony_ci 387370b324cSopenharmony_ci}} 388370b324cSopenharmony_ci 389370b324cSopenharmony_ci 390370b324cSopenharmony_ci#endif 391