Update README.md
[nemesis.git] / Platform / FileStream.h
1 /*
2  Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
3
4  Governed by the TrueCrypt License 3.0 the full text of which is contained in
5  the file License.txt included in TrueCrypt binary and source code distribution
6  packages.
7 */
8
9 #ifndef TC_HEADER_Platform_FileStream
10 #define TC_HEADER_Platform_FileStream
11
12 #include "PlatformBase.h"
13 #include "File.h"
14 #include "SharedPtr.h"
15 #include "Stream.h"
16
17 namespace TrueCrypt
18 {
19         class FileStream : public Stream
20         {
21         public:
22                 FileStream (shared_ptr <File> file) : DataFile (file) { }
23                 FileStream (File::SystemFileHandleType openFileHandle) { DataFile.reset (new File ()); DataFile->AssignSystemHandle (openFileHandle); }
24                 virtual ~FileStream () { }
25
26                 virtual uint64 Read (const BufferPtr &buffer)
27                 {
28                         return DataFile->Read (buffer);
29                 }
30
31                 virtual void ReadCompleteBuffer (const BufferPtr &buffer)
32                 {
33                         DataFile->ReadCompleteBuffer (buffer);
34                 }
35
36                 virtual string ReadToEnd ()
37                 {
38                         string str;
39                         vector <char> buffer (4096);
40                         uint64 len;
41
42                         while ((len = DataFile->Read (BufferPtr (reinterpret_cast <byte *> (&buffer[0]), buffer.size()))) > 0)
43                                 str.insert (str.end(), buffer.begin(), buffer.begin() + static_cast <int> (len));
44
45                         return str;
46                 }
47
48                 virtual void Write (const ConstBufferPtr &data)
49                 {
50                         DataFile->Write (data);
51                 }
52
53         protected:
54                 shared_ptr <File> DataFile;
55         };
56 }
57
58 #endif // TC_HEADER_Platform_FileStream
This page took 0.016157 seconds and 3 git commands to generate. Download a nemesis OSX (sierra+high sierra, tested/working) binary, with fuse-ext3 via e2fsprogs, at this link. application and installer are signed by screwjack, llc. must install fuse with macFUSE layer first.