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 vdirectiofilestream_h 00009 #define vdirectiofilestream_h 00010 00013 #include "vabstractfilestream.h" 00014 00015 class VFSNode; 00016 00032 class VDirectIOFileStream : public VAbstractFileStream { 00033 public: 00034 00039 VDirectIOFileStream(); 00044 VDirectIOFileStream(const VFSNode& node); 00053 VDirectIOFileStream(int fd, bool closeOnDestruct); 00058 virtual ~VDirectIOFileStream(); 00059 00070 void setFile(int fd, 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 VDirectIOFileStream(const VDirectIOFileStream& other); 00155 VDirectIOFileStream& operator=(const VDirectIOFileStream& other); 00156 00157 int mFile; 00158 bool mCloseOnDestruct; 00159 }; 00160 00161 #endif /* vdirectiofilestream_h */ 00162