Vault
4.1
|
00001 /* 00002 Copyright c1997-2014 Trygve Isaacson. All rights reserved. 00003 This file is part of the Code Vault version 4.1 00004 http://www.bombaydigital.com/ 00005 License: MIT. See LICENSE.md in the Vault top level directory. 00006 */ 00007 00008 #ifndef vbufferedfilestream_h 00009 #define vbufferedfilestream_h 00010 00013 #include "vabstractfilestream.h" 00014 00015 class VFSNode; 00016 00032 class VBufferedFileStream : public VAbstractFileStream { 00033 public: 00034 00039 VBufferedFileStream(); 00044 VBufferedFileStream(const VFSNode& node); 00053 VBufferedFileStream(FILE* f, bool closeOnDestruct); 00058 virtual ~VBufferedFileStream(); 00059 00070 void setFile(FILE* f, bool closeOnDestruct); 00071 00072 // Implementation of VAbstractFileStream ----------------------------- 00073 00077 virtual void openReadOnly(); 00082 virtual void openReadWrite(); 00087 virtual void openWrite(); 00091 virtual bool isOpen() const; 00095 virtual void close(); 00096 00097 // Implementation of VStream ----------------------------------------- 00098 00105 virtual Vs64 read(Vu8* targetBuffer, Vs64 numBytesToRead); 00112 virtual Vs64 write(const Vu8* buffer, Vs64 numBytesToWrite); 00118 virtual void flush(); 00126 virtual bool skip(Vs64 numBytesToSkip); 00133 virtual bool seek(Vs64 offset, int whence); 00139 virtual Vs64 getIOOffset() const; 00149 virtual Vs64 available() const; 00150 00151 private: 00152 00153 // Prevent copy construction and assignment, since there is no provision for sharing the mFile pointer. 00154 VBufferedFileStream(const VBufferedFileStream& other); 00155 VBufferedFileStream& operator=(const VBufferedFileStream& other); 00156 00157 FILE* mFile; 00158 bool mCloseOnDestruct; 00159 00160 }; 00161 00162 #endif /* vbufferedfilestream_h */ 00163