other-licenses/7zstub/src/Windows/FileIO.h

branch
TOR_BUG_9701
changeset 14
925c144e1f1f
equal deleted inserted replaced
-1:000000000000 0:6e4c2bf56a21
1 // Windows/FileIO.h
2
3 #ifndef __WINDOWS_FILEIO_H
4 #define __WINDOWS_FILEIO_H
5
6 #include "../Common/Types.h"
7
8 namespace NWindows {
9 namespace NFile {
10 namespace NIO {
11
12 struct CByHandleFileInfo
13 {
14 DWORD Attributes;
15 FILETIME CreationTime;
16 FILETIME LastAccessTime;
17 FILETIME LastWriteTime;
18 DWORD VolumeSerialNumber;
19 UInt64 Size;
20 DWORD NumberOfLinks;
21 UInt64 FileIndex;
22 };
23
24 class CFileBase
25 {
26 protected:
27 bool _fileIsOpen;
28 HANDLE _handle;
29 bool Create(LPCTSTR fileName, DWORD desiredAccess,
30 DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
31 #ifndef _UNICODE
32 bool Create(LPCWSTR fileName, DWORD desiredAccess,
33 DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
34 #endif
35
36 public:
37 CFileBase(): _fileIsOpen(false){};
38 virtual ~CFileBase();
39
40 virtual bool Close();
41
42 bool GetPosition(UInt64 &position) const;
43 bool GetLength(UInt64 &length) const;
44
45 bool Seek(Int64 distanceToMove, DWORD moveMethod, UInt64 &newPosition) const;
46 bool Seek(UInt64 position, UInt64 &newPosition);
47 bool SeekToBegin();
48 bool SeekToEnd(UInt64 &newPosition);
49
50 bool GetFileInformation(CByHandleFileInfo &fileInfo) const;
51 };
52
53 class CInFile: public CFileBase
54 {
55 public:
56 bool Open(LPCTSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
57 bool Open(LPCTSTR fileName);
58 #ifndef _UNICODE
59 bool Open(LPCWSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
60 bool Open(LPCWSTR fileName);
61 #endif
62 bool ReadPart(void *data, UInt32 size, UInt32 &processedSize);
63 bool Read(void *data, UInt32 size, UInt32 &processedSize);
64 };
65
66 class COutFile: public CFileBase
67 {
68 // DWORD m_CreationDisposition;
69 public:
70 // COutFile(): m_CreationDisposition(CREATE_NEW){};
71 bool Open(LPCTSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
72 bool Open(LPCTSTR fileName, DWORD creationDisposition);
73 bool Create(LPCTSTR fileName, bool createAlways);
74
75 #ifndef _UNICODE
76 bool Open(LPCWSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
77 bool Open(LPCWSTR fileName, DWORD creationDisposition);
78 bool Create(LPCWSTR fileName, bool createAlways);
79 #endif
80
81 /*
82 void SetOpenCreationDisposition(DWORD creationDisposition)
83 { m_CreationDisposition = creationDisposition; }
84 void SetOpenCreationDispositionCreateAlways()
85 { m_CreationDisposition = CREATE_ALWAYS; }
86 */
87
88 bool SetTime(const FILETIME *creationTime, const FILETIME *lastAccessTime, const FILETIME *lastWriteTime);
89 bool SetLastWriteTime(const FILETIME *lastWriteTime);
90 bool WritePart(const void *data, UInt32 size, UInt32 &processedSize);
91 bool Write(const void *data, UInt32 size, UInt32 &processedSize);
92 bool SetEndOfFile();
93 bool SetLength(UInt64 length);
94 };
95
96 }}}
97
98 #endif

mercurial