Annotation of truecrypt/platform/filestream.h, revision 1.1

1.1     ! root        1: /*
        !             2:  Copyright (c) 2008 TrueCrypt Foundation. All rights reserved.
        !             3: 
        !             4:  Governed by the TrueCrypt License 2.4 the full text of which is contained
        !             5:  in the file License.txt included in TrueCrypt binary and source code
        !             6:  distribution 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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.