| 1 |
// FileStreams.h |
| 2 |
|
| 3 |
#ifndef __FILESTREAMS_H |
| 4 |
#define __FILESTREAMS_H |
| 5 |
|
| 6 |
#ifdef _WIN32 |
| 7 |
#include "../../Windows/FileIO.h" |
| 8 |
#else |
| 9 |
#include "../../Common/C_FileIO.h" |
| 10 |
#endif |
| 11 |
|
| 12 |
#include "../IStream.h" |
| 13 |
#include "../../Common/MyCom.h" |
| 14 |
|
| 15 |
class CInFileStream: |
| 16 |
public IInStream, |
| 17 |
public IStreamGetSize, |
| 18 |
public CMyUnknownImp |
| 19 |
{ |
| 20 |
public: |
| 21 |
#ifdef _WIN32 |
| 22 |
NWindows::NFile::NIO::CInFile File; |
| 23 |
#else |
| 24 |
NC::NFile::NIO::CInFile File; |
| 25 |
#endif |
| 26 |
CInFileStream() {} |
| 27 |
virtual ~CInFileStream() {} |
| 28 |
|
| 29 |
bool Open(LPCTSTR fileName); |
| 30 |
#ifdef _WIN32 |
| 31 |
#ifndef _UNICODE |
| 32 |
bool Open(LPCWSTR fileName); |
| 33 |
#endif |
| 34 |
#endif |
| 35 |
|
| 36 |
MY_UNKNOWN_IMP2(IInStream, IStreamGetSize) |
| 37 |
|
| 38 |
STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize); |
| 39 |
STDMETHOD(ReadPart)(void *data, UInt32 size, UInt32 *processedSize); |
| 40 |
STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition); |
| 41 |
|
| 42 |
STDMETHOD(GetSize)(UInt64 *size); |
| 43 |
}; |
| 44 |
|
| 45 |
#ifndef _WIN32_WCE |
| 46 |
class CStdInFileStream: |
| 47 |
public ISequentialInStream, |
| 48 |
public CMyUnknownImp |
| 49 |
{ |
| 50 |
public: |
| 51 |
// HANDLE File; |
| 52 |
// CStdInFileStream() File(INVALID_HANDLE_VALUE): {} |
| 53 |
// void Open() { File = GetStdHandle(STD_INPUT_HANDLE); }; |
| 54 |
MY_UNKNOWN_IMP |
| 55 |
|
| 56 |
virtual ~CStdInFileStream() {} |
| 57 |
STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize); |
| 58 |
STDMETHOD(ReadPart)(void *data, UInt32 size, UInt32 *processedSize); |
| 59 |
}; |
| 60 |
#endif |
| 61 |
|
| 62 |
class COutFileStream: |
| 63 |
public IOutStream, |
| 64 |
public CMyUnknownImp |
| 65 |
{ |
| 66 |
public: |
| 67 |
#ifdef _WIN32 |
| 68 |
NWindows::NFile::NIO::COutFile File; |
| 69 |
#else |
| 70 |
NC::NFile::NIO::COutFile File; |
| 71 |
#endif |
| 72 |
virtual ~COutFileStream() {} |
| 73 |
bool Create(LPCTSTR fileName, bool createAlways); |
| 74 |
#ifdef _WIN32 |
| 75 |
#ifndef _UNICODE |
| 76 |
bool Create(LPCWSTR fileName, bool createAlways); |
| 77 |
#endif |
| 78 |
#endif |
| 79 |
|
| 80 |
MY_UNKNOWN_IMP1(IOutStream) |
| 81 |
|
| 82 |
STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize); |
| 83 |
STDMETHOD(WritePart)(const void *data, UInt32 size, UInt32 *processedSize); |
| 84 |
STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition); |
| 85 |
STDMETHOD(SetSize)(Int64 newSize); |
| 86 |
}; |
| 87 |
|
| 88 |
#ifndef _WIN32_WCE |
| 89 |
class CStdOutFileStream: |
| 90 |
public ISequentialOutStream, |
| 91 |
public CMyUnknownImp |
| 92 |
{ |
| 93 |
public: |
| 94 |
MY_UNKNOWN_IMP |
| 95 |
|
| 96 |
virtual ~CStdOutFileStream() {} |
| 97 |
STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize); |
| 98 |
STDMETHOD(WritePart)(const void *data, UInt32 size, UInt32 *processedSize); |
| 99 |
}; |
| 100 |
#endif |
| 101 |
|
| 102 |
#endif |