OLD | NEW |
| (Empty) |
1 // FileStreams.h | |
2 | |
3 #ifndef __FILESTREAMS_H | |
4 #define __FILESTREAMS_H | |
5 | |
6 #ifdef _WIN32 | |
7 #define USE_WIN_FILE | |
8 #endif | |
9 | |
10 #ifdef USE_WIN_FILE | |
11 #include "../../Windows/FileIO.h" | |
12 #else | |
13 #include "../../Common/C_FileIO.h" | |
14 #endif | |
15 | |
16 #include "../IStream.h" | |
17 #include "../../Common/MyCom.h" | |
18 | |
19 class CInFileStream: | |
20 public IInStream, | |
21 public IStreamGetSize, | |
22 public CMyUnknownImp | |
23 { | |
24 public: | |
25 #ifdef USE_WIN_FILE | |
26 NWindows::NFile::NIO::CInFile File; | |
27 #else | |
28 NC::NFile::NIO::CInFile File; | |
29 #endif | |
30 CInFileStream() {} | |
31 virtual ~CInFileStream() {} | |
32 | |
33 bool Open(LPCTSTR fileName); | |
34 #ifdef USE_WIN_FILE | |
35 #ifndef _UNICODE | |
36 bool Open(LPCWSTR fileName); | |
37 #endif | |
38 #endif | |
39 | |
40 bool OpenShared(LPCTSTR fileName, bool shareForWrite); | |
41 #ifdef USE_WIN_FILE | |
42 #ifndef _UNICODE | |
43 bool OpenShared(LPCWSTR fileName, bool shareForWrite); | |
44 #endif | |
45 #endif | |
46 | |
47 MY_UNKNOWN_IMP2(IInStream, IStreamGetSize) | |
48 | |
49 STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize); | |
50 STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition); | |
51 | |
52 STDMETHOD(GetSize)(UInt64 *size); | |
53 }; | |
54 | |
55 #ifndef _WIN32_WCE | |
56 class CStdInFileStream: | |
57 public ISequentialInStream, | |
58 public CMyUnknownImp | |
59 { | |
60 public: | |
61 // HANDLE File; | |
62 // CStdInFileStream() File(INVALID_HANDLE_VALUE): {} | |
63 // void Open() { File = GetStdHandle(STD_INPUT_HANDLE); }; | |
64 MY_UNKNOWN_IMP | |
65 | |
66 virtual ~CStdInFileStream() {} | |
67 STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize); | |
68 }; | |
69 #endif | |
70 | |
71 class COutFileStream: | |
72 public IOutStream, | |
73 public CMyUnknownImp | |
74 { | |
75 #ifdef USE_WIN_FILE | |
76 NWindows::NFile::NIO::COutFile File; | |
77 #else | |
78 NC::NFile::NIO::COutFile File; | |
79 #endif | |
80 public: | |
81 virtual ~COutFileStream() {} | |
82 bool Create(LPCTSTR fileName, bool createAlways) | |
83 { | |
84 ProcessedSize = 0; | |
85 return File.Create(fileName, createAlways); | |
86 } | |
87 bool Open(LPCTSTR fileName, DWORD creationDisposition) | |
88 { | |
89 ProcessedSize = 0; | |
90 return File.Open(fileName, creationDisposition); | |
91 } | |
92 #ifdef USE_WIN_FILE | |
93 #ifndef _UNICODE | |
94 bool Create(LPCWSTR fileName, bool createAlways) | |
95 { | |
96 ProcessedSize = 0; | |
97 return File.Create(fileName, createAlways); | |
98 } | |
99 bool Open(LPCWSTR fileName, DWORD creationDisposition) | |
100 { | |
101 ProcessedSize = 0; | |
102 return File.Open(fileName, creationDisposition); | |
103 } | |
104 #endif | |
105 #endif | |
106 | |
107 HRESULT Close(); | |
108 | |
109 UInt64 ProcessedSize; | |
110 | |
111 #ifdef USE_WIN_FILE | |
112 bool SetTime(const FILETIME *cTime, const FILETIME *aTime, const FILETIME *mTi
me) | |
113 { | |
114 return File.SetTime(cTime, aTime, mTime); | |
115 } | |
116 bool SetMTime(const FILETIME *mTime) { return File.SetMTime(mTime); } | |
117 #endif | |
118 | |
119 | |
120 MY_UNKNOWN_IMP1(IOutStream) | |
121 | |
122 STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize); | |
123 STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition); | |
124 STDMETHOD(SetSize)(Int64 newSize); | |
125 }; | |
126 | |
127 #ifndef _WIN32_WCE | |
128 class CStdOutFileStream: | |
129 public ISequentialOutStream, | |
130 public CMyUnknownImp | |
131 { | |
132 public: | |
133 MY_UNKNOWN_IMP | |
134 | |
135 virtual ~CStdOutFileStream() {} | |
136 STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize); | |
137 }; | |
138 #endif | |
139 | |
140 #endif | |
OLD | NEW |