23 if (!
open(fileName, append))
25 "Error creating/opening for write file: '%s'", fileName.c_str());
36 ios_base::openmode openMode = ios_base::binary | ios_base::out;
37 if (append) openMode |= ios_base::app;
39 m_of.open(fileName.c_str(), openMode);
40 return m_of.is_open();
58 if (!
m_of.is_open())
return 0;
60 m_of.write(static_cast<const char*>(Buffer), Count);
61 return m_of.fail() ? 0 : Count;
66 if (!
m_of.is_open())
return 0;
68 ofstream::off_type
offset = Offset;
69 ofstream::seekdir way;
94 auto& f =
const_cast<std::ofstream&
>(
m_of);
96 const uint64_t previousPos = f.tellp();
99 f.seekp(previousPos, ios_base::beg);
105 auto& f =
const_cast<std::ofstream&
>(
m_of);
TSeekOrigin
Used in CStream::Seek.
uint64_t getPosition() const override
Method for getting the current cursor position, where 0 is the first byte and TotalBytesCount-1 the l...
#define THROW_EXCEPTION(msg)
uint64_t Seek(int64_t Offset, CStream::TSeekOrigin Origin=sFromBeginning) override
Introduces a pure virtual method for moving to a specified position in the streamed resource...
CFileOutputStream()
Default constructor.
std::ofstream m_of
The actual output file stream.
bool fileOpenCorrectly() const
Returns true if the file was open without errors.
bool open(const std::string &fileName, bool append=false)
Open the given file for write.
unsigned __int64 uint64_t
uint64_t getTotalBytesCount() const override
Method for getting the total number of bytes writen to buffer.
size_t Read(void *Buffer, size_t Count) override
Introduces a pure virtual method responsible for reading from the stream.
size_t Write(const void *Buffer, size_t Count) override
Introduces a pure virtual method responsible for writing to the stream.
void close()
Close the stream.
#define THROW_EXCEPTION_FMT(_FORMAT_STRING,...)
virtual ~CFileOutputStream()
Destructor.
#define MRPT_UNUSED_PARAM(a)
Determines whether this is an X86 or AMD64 platform.