8 #ifndef __FILESTREAM_HPP__ 9 #define __FILESTREAM_HPP__ 11 #include "PrintStream.hpp" 19 FileStream(
char const *path, std::ios_base::openmode mode,
bool verifyWrites =
false);
21 virtual void write(
void const *data,
long length);
22 virtual void read(
void *data,
long length);
23 virtual void setOutPos(
long pos, std::ios_base::seekdir seekAnchor);
24 virtual void setOutPos(
long pos,
bool fromBeginning);
25 virtual void setInPos(
long pos, std::ios_base::seekdir seekAnchor);
26 virtual void setInPos(
long pos,
bool fromBeginning);
27 bool readable() {
return mMode & std::ios_base::in; }
28 bool writeable() {
return mMode & std::ios_base::out; }
29 bool binary() {
return mFStream.flags() & std::ios_base::binary; }
30 bool readwrite() {
return readable() && writeable(); }
33 std::string
const &getFileName()
const {
return mFileName; }
37 void verifyFlags(
const char *caller);
38 void openFile(
char const *path, std::ios_base::openmode mode,
bool verifyWrites);
40 std::fstream mFStream;
41 std::string mFileName;
44 std::ios_base::openmode mMode;
45 bool mVerifyWrites =
false;
46 int const mMaxAttempts = 5;