OpenTTD Source: FileWriter Struct Reference

OpenTTD Source 14.1

Public Member Functions | Data Fields
FileWriter Struct Reference

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

Inheritance diagram for FileWriter:

## Public Member Functions
| FileWriter (FILE *file)
| Create the file writer, so it writes to a specific file. More...
| ~FileWriter ()
| Make sure everything is cleaned up.
void | Write (byte *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
FILE * | file
| 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< SaveFilter > | chain
| Chained to the (savegame) filters.

## Detailed Description

Yes, simply writing to a file.

Base class for writing data to disk.

Definition at line 2210 of file saveload.cpp.

## Constructor & Destructor Documentation

## ◆ FileWriter() [1/2]

FileWriter::FileWriter | ( | FILE * | file | ) |
| inline

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

Parameters

  file | The file to write to.

Definition at line 2217 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

  path | The path to the file to open.
  openmode | The openmode flags for opening the file.

Definition at line 200 of file strgen.cpp.

References path.

## Member Function Documentation

## ◆ Write()

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

Write a given number of bytes into the savegame.

Parameters

  buf | The bytes to write.
  len | The number of bytes to write.

Implements SaveFilter.

Definition at line 2227 of file saveload.cpp.

References SlError().

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

- src/saveload/saveload.cpp
- src/strgen/strgen.cpp