|
xoreos
0.0.5
|
A simple streaming file writing class. More...
#include <writefile.h>


Public Member Functions | |
| WriteFile () | |
| WriteFile (const UString &fileName) | |
| ~WriteFile () | |
| bool | open (const UString &fileName) |
| Try to open the file with the given fileName. More... | |
| void | close () |
| Close the file, if open. More... | |
| bool | isOpen () const |
| Checks if the object opened a file successfully. More... | |
| void | flush () |
| Commit any buffered data to the underlying channel or storage medium; unbuffered streams can use the default implementation. More... | |
| size_t | write (const void *dataPtr, size_t dataSize) |
| Write data into the stream. More... | |
| size_t | size () const |
| Return the number of bytes written to the current file in total. More... | |
| size_t | pos () const |
| Return the current position ot the stream in the file. More... | |
| size_t | seek (ptrdiff_t offset, Origin whence=SeekableWriteStream::kOriginBegin) |
| Seek to the speciied offset from the specified origin. More... | |
Public Member Functions inherited from Common::SeekableWriteStream | |
| SeekableWriteStream () | |
| ~SeekableWriteStream () | |
| virtual size_t | skip (ptrdiff_t offset) |
| Skip the specified number of bytes, adding that offset to the current position in the stream. More... | |
Public Member Functions inherited from Common::WriteStream | |
| WriteStream () | |
| virtual | ~WriteStream () |
| void | writeByte (byte value) |
| void | writeSByte (int8 value) |
| void | writeUint16LE (uint16 value) |
| void | writeUint32LE (uint32 value) |
| void | writeUint64LE (uint64 value) |
| void | writeUint16BE (uint16 value) |
| void | writeUint32BE (uint32 value) |
| void | writeUint64BE (uint64 value) |
| void | writeBytes (byte value, size_t n) |
| Write n bytes of value to the stream. More... | |
| FORCEINLINE void | writeZeros (size_t n) |
| Write n zeros to the stream. More... | |
| FORCEINLINE void | writeSint16LE (int16 value) |
| FORCEINLINE void | writeSint32LE (int32 value) |
| FORCEINLINE void | writeSint64LE (int64 value) |
| FORCEINLINE void | writeSint16BE (int16 value) |
| FORCEINLINE void | writeSint32BE (int32 value) |
| FORCEINLINE void | writeSint64BE (int64 value) |
| FORCEINLINE void | writeIEEEFloatLE (float value) |
| FORCEINLINE void | writeIEEEFloatBE (float value) |
| FORCEINLINE void | writeIEEEDoubleLE (double value) |
| FORCEINLINE void | writeIEEEDoubleBE (double value) |
| size_t | writeStream (ReadStream &stream, size_t n) |
| Copy n bytes of the given stream into the stream. More... | |
| size_t | writeStream (ReadStream &stream) |
| Copy the complete contents of the given stream. More... | |
| void | writeString (const UString &str) |
| Write the given string to the stream, encoded as UTF-8. More... | |
Protected Attributes | |
| std::FILE * | _handle |
| The actual file handle. More... | |
| size_t | _size |
Additional Inherited Members | |
Public Types inherited from Common::SeekableWriteStream | |
| enum | Origin { kOriginBegin = 0, kOriginCurrent = 1, kOriginEnd = 2, kOriginMAX } |
| The position a seeking offset takes as a base. More... | |
Static Public Member Functions inherited from Common::SeekableWriteStream | |
| static size_t | evalSeek (ptrdiff_t offset, Origin whence, size_t pos, size_t begin, size_t size) |
| Evaluate the seek offset relative to whence into a position from the beginning. More... | |
A simple streaming file writing class.
Definition at line 40 of file writefile.h.
| Common::WriteFile::WriteFile | ( | ) |
Definition at line 35 of file writefile.cpp.
| Common::WriteFile::WriteFile | ( | const UString & | fileName | ) |
Definition at line 38 of file writefile.cpp.
References Common::UString::c_str(), and open().

| Common::WriteFile::~WriteFile | ( | ) |
Definition at line 43 of file writefile.cpp.
References close().

| void Common::WriteFile::close | ( | ) |
Close the file, if open.
Definition at line 69 of file writefile.cpp.
References _handle, _size, and flush().
Referenced by Common::DebugManager::closeLogFile(), Engines::ConsoleWindow::closeLogFile(), Aurora::ResourceManager::dumpResourcesList(), Engines::dumpStream(), open(), Engines::ConsoleWindow::setRedirect(), Aurora::TwoDAFile::writeASCII(), Aurora::TwoDAFile::writeBinary(), Graphics::writeBMP(), Aurora::TwoDAFile::writeCSV(), Aurora::SSFFile::writeSSF(), Engines::ConsoleWindow::~ConsoleWindow(), and ~WriteFile().


|
virtual |
Commit any buffered data to the underlying channel or storage medium; unbuffered streams can use the default implementation.
When flushing fails, a kWriteError exception is thrown.
Reimplemented from Common::WriteStream.
Definition at line 83 of file writefile.cpp.
References _handle, and Common::kWriteError.
Referenced by close(), Aurora::ResourceManager::dumpResourcesList(), Engines::dumpStream(), Common::DebugManager::logString(), Engines::ConsoleWindow::printLine(), Engines::ConsoleWindow::setRedirect(), Graphics::writeBMP(), and Engines::ConsoleWindow::~ConsoleWindow().

| bool Common::WriteFile::isOpen | ( | ) | const |
Checks if the object opened a file successfully.
Definition at line 79 of file writefile.cpp.
References _handle.
Referenced by Common::DebugManager::logString(), and Engines::ConsoleWindow::printLine().

| bool Common::WriteFile::open | ( | const UString & | fileName | ) |
Try to open the file with the given fileName.
| fileName | the name of the file to open |
Definition at line 50 of file writefile.cpp.
References _handle, close(), Common::FilePath::createDirectories(), Common::UString::empty(), Common::FilePath::getDirectory(), Common::Platform::kFileModeWrite, Common::FilePath::normalize(), and Common::Platform::openFile().
Referenced by Aurora::ResourceManager::dumpResourcesList(), Engines::dumpStream(), Common::DebugManager::openLogFile(), Engines::ConsoleWindow::openLogFile(), Common::ConfigManager::save(), Engines::ConsoleWindow::setRedirect(), Aurora::TwoDAFile::writeASCII(), Aurora::TwoDAFile::writeBinary(), Graphics::writeBMP(), Aurora::TwoDAFile::writeCSV(), WriteFile(), and Aurora::SSFFile::writeSSF().


|
virtual |
Return the current position ot the stream in the file.
Implements Common::SeekableWriteStream.
Definition at line 108 of file writefile.cpp.
References _handle.
Referenced by seek(), and write().

|
virtual |
Seek to the speciied offset from the specified origin.
Implements Common::SeekableWriteStream.
Definition at line 112 of file writefile.cpp.
References _handle, _size, Common::SeekableWriteStream::evalSeek(), Common::kSeekError, pos(), and size().

|
virtual |
Return the number of bytes written to the current file in total.
Implements Common::SeekableWriteStream.
Definition at line 104 of file writefile.cpp.
References _size.
Referenced by seek(), and write().

|
virtual |
Write data into the stream.
Subclasses must implement this method; all other write methods are implemented using it.
| dataPtr | pointer to the data to be written. |
| dataSize | number of bytes to be written. |
Implements Common::WriteStream.
Definition at line 91 of file writefile.cpp.
References _handle, _size, pos(), and size().
Referenced by Graphics::writeBMP().


|
protected |
|
protected |
1.8.14