14 # define _SCL_SECURE_NO_WARNINGS 39 else if (mode_==
fomWrite)
mode = std::ios_base::out | std::ios_base::trunc;
40 else if (mode_==
fomAppend)
mode = std::ios_base::app | std::ios_base::out;
45 m_f.open(fileName.c_str(),
mode);
60 else if (mode_==
fomWrite)
mode = std::ios_base::out | std::ios_base::trunc;
61 else if (mode_==
fomAppend)
mode = std::ios_base::app | std::ios_base::out;
68 m_f.open(fileName.c_str(), ios_base::binary |
mode );
97 if (!
m_f.is_open())
return 0;
98 m_f.read(static_cast<char*>(Buffer),Count);
99 return m_f.fail() ? 0:Count;
108 if (!
m_f.is_open())
return 0;
110 m_f.write( static_cast<const char*>(Buffer),Count);
111 return m_f.fail() ? 0:Count;
121 if (!
m_f.is_open())
return 0;
123 fstream::off_type
offset = Offset;
124 fstream::seekdir way;
188 return m_f.is_open();
197 if (!
m_f.is_open())
return false;
199 std::getline(
m_f, str );
200 return !
m_f.fail() && !
m_f.eof();
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.
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 Seek(int64_t Offset, CStream::TSeekOrigin Origin=sFromBeginning) MRPT_OVERRIDE
Method for moving to a specified position in the streamed resource.
uint64_t getPositionO()
The current Input cursor position, where 0 is the first byte.
GLsizei const GLchar ** string
void clearError()
Resets stream error status bits (e.g. after an EOF)
virtual ~CFileStream()
Destructor.
unsigned __int64 uint64_t
uint64_t getTotalBytesCount() MRPT_OVERRIDE
Method for getting the total number of bytes writen to buffer.
CFileStream()
Constructor.
size_t Write(const void *Buffer, size_t Count) MRPT_OVERRIDE
Introduces a pure virtual method responsible for writing to the stream.
size_t Read(void *Buffer, size_t Count) MRPT_OVERRIDE
Introduces a pure virtual method responsible for reading from the stream.
uint64_t getPosition() MRPT_OVERRIDE
Method for getting the current cursor position, where 0 is the first byte and TotalBytesCount-1 the l...
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.