other-licenses/7zstub/src/7zip/Common/FileStreams.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

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

mercurial