OpenTTD Source  20241108-master-g80f628063a
FileWriter Struct Reference

Yes, simply writing to a file. More...

Inheritance diagram for FileWriter:
SaveFilter HeaderFileWriter LanguageFileWriter

Public Member Functions

 FileWriter (FileHandle &&file)
 Create the file writer, so it writes to a specific file. More...
 
 ~FileWriter ()
 Make sure everything is cleaned up.
 
void Write (uint8_t *buf, size_t size) override
 Write a given number of bytes into the savegame. More...
 
void Finish () override
 Prepare everything to finish writing the savegame.
 
 FileWriter (const std::filesystem::path &path, std::ios_base::openmode openmode)
 Open a file to write to. More...
 
void Finalise ()
 Finalise the writing.
 
virtual ~FileWriter ()
 Make sure the file is closed.
 
- Public Member Functions inherited from SaveFilter
 SaveFilter (std::shared_ptr< SaveFilter > chain)
 Initialise this filter. More...
 
virtual ~SaveFilter ()
 Make sure the writers are properly closed.
 

Data Fields

std::optional< FileHandlefile
 The file to write to.
 
std::ofstream output_stream
 The stream to write all the output to.
 
const std::filesystem::path path
 The file name we're writing to.
 
- Data Fields inherited from SaveFilter
std::shared_ptr< SaveFilterchain
 Chained to the (savegame) filters.
 

Detailed Description

Yes, simply writing to a file.

Base class for writing data to disk.

Definition at line 2244 of file saveload.cpp.

Constructor & Destructor Documentation

◆ FileWriter() [1/2]

FileWriter::FileWriter ( FileHandle &&  file)
inline

Create the file writer, so it writes to a specific file.

Parameters
fileThe file to write to.

Definition at line 2251 of file saveload.cpp.

◆ FileWriter() [2/2]

FileWriter::FileWriter ( const std::filesystem::path &  path,
std::ios_base::openmode  openmode 
)
inline

Open a file to write to.

Parameters
pathThe path to the file to open.
openmodeThe openmode flags for opening the file.

Definition at line 200 of file strgen.cpp.

References path.

Member Function Documentation

◆ Write()

void FileWriter::Write ( uint8_t *  buf,
size_t  len 
)
inlineoverridevirtual

Write a given number of bytes into the savegame.

Parameters
bufThe bytes to write.
lenThe number of bytes to write.

Implements SaveFilter.

Definition at line 2261 of file saveload.cpp.

References SlError().


The documentation for this struct was generated from the following files: