RLLib  0.1
Public Member Functions | List of all members
rl::FileWriter Class Reference

The file reader provides features to write bytes into a binary file. More...

#include <FileWriter.hpp>

Public Member Functions

 FileWriter (const FilePath &path, bool truncate=false)
 Creates and opens a file with writing permissions. More...
 
void open (const FilePath &path, bool truncate=false)
 Opens a file with writing permissions. More...
 
 operator bool () const
 Tells if the file is in a good state. More...
 
void write (const ByteStream &buffer)
 Writes a chunk of bytes into the file. More...
 
void write (const ByteStream &buffer, std::streampos pos)
 Writes a chunk of bytes into a specific position in the file. More...
 

Detailed Description

The file reader provides features to write bytes into a binary file.

Constructor & Destructor Documentation

◆ FileWriter()

rl::FileWriter::FileWriter ( const FilePath path,
bool  truncate = false 
)
explicit

Creates and opens a file with writing permissions.

If the file does not exist, it is created. If the file already exists, the original content can be either kept or discarded.

Parameters
pathThe path to the file
truncatetrue to discard the original content, false to keep it

Member Function Documentation

◆ open()

void rl::FileWriter::open ( const FilePath path,
bool  truncate = false 
)

Opens a file with writing permissions.

If the file does not exist, it is created. If the file already exists, the original content can be either kept or discarded.

Parameters
pathThe path to the file
truncatetrue to discard the original content, false to keep it

◆ operator bool()

rl::FileWriter::operator bool ( ) const

Tells if the file is in a good state.

Returns
true if no errors occurred while writing into the file, false if something went wrong

◆ write() [1/2]

void rl::FileWriter::write ( const ByteStream buffer)

Writes a chunk of bytes into the file.

Parameters
bufferThe data stream containing the bytes that are to be written

◆ write() [2/2]

void rl::FileWriter::write ( const ByteStream buffer,
std::streampos  pos 
)

Writes a chunk of bytes into a specific position in the file.

Parameters
bufferThe data stream containing the bytes that are to be written
posThe position of the file cursor

The documentation for this class was generated from the following file: