13 #define _SCL_SECURE_NO_WARNINGS 37 mode = std::ios_base::out | std::ios_base::trunc;
39 mode = std::ios_base::app | std::ios_base::out;
46 m_f.open(fileName.c_str(),
mode);
63 mode = std::ios_base::out | std::ios_base::trunc;
65 mode = std::ios_base::app | std::ios_base::out;
71 if (
m_f.is_open())
m_f.close();
73 m_f.open(fileName.c_str(), ios_base::binary |
mode);
93 if (!
m_f.is_open())
return 0;
94 m_f.read(static_cast<char*>(Buffer), Count);
95 return m_f.fail() ? 0 : Count;
104 if (!
m_f.is_open())
return 0;
106 m_f.write(static_cast<const char*>(Buffer), Count);
107 return m_f.fail() ? 0 : Count;
117 if (!
m_f.is_open())
return 0;
119 fstream::off_type
offset = Offset;
120 fstream::seekdir way;
199 if (!
m_f.is_open())
return false;
201 std::getline(
m_f, str);
202 return !
m_f.fail() && !
m_f.eof();
210 if (!
m_f.is_open())
return true;
bool readLine(std::string &str)
Reads one string line from the file (until a new-line character)
bool fileOpenCorrectly()
Returns true if the file was open without errors.
size_t Write(const void *Buffer, size_t Count) override
Introduces a pure virtual method responsible for writing to the stream.
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
std::fstream m_f
The actual input file stream.
TSeekOrigin
Used in CStream::Seek.
void close()
Closes the file.
#define THROW_EXCEPTION(msg)
#define THROW_EXCEPTION_FMT(_FORMAT_STRING,...)
uint64_t getPositionI()
The current Input cursor position, where 0 is the first byte.
int TFileOpenModes
File open modes are used in CFileStream Posible values are:
uint64_t getPosition() override
Method for getting the current cursor position, where 0 is the first byte and TotalBytesCount-1 the l...
uint64_t getPositionO()
The current Input cursor position, where 0 is the first byte.
GLsizei const GLchar ** string
virtual ~CFileStream()
Destructor.
unsigned __int64 uint64_t
uint64_t getTotalBytesCount() override
Method for getting the total number of bytes writen to buffer.
CFileStream()
Constructor.
size_t Read(void *Buffer, size_t Count) override
Introduces a pure virtual method responsible for reading from the stream.
uint64_t Seek(uint64_t Offset, CStream::TSeekOrigin Origin=sFromBeginning) override
Method for moving to a specified position in the streamed resource.
bool checkEOF()
Will be true if EOF has been already reached.
bool open(const std::string &fileName, TFileOpenModes mode=fomRead|fomWrite)
Opens the file, returning true on success.