67 constexpr bool operator==(
const FiosType &)
const noexcept =
default;
141 static std::optional<FileHandle>
Open(
const std::string &filename, std::string_view mode);
150 static std::optional<FileHandle>
Open(std::string_view filename, std::string_view mode) {
return FileHandle::Open(std::string{filename}, mode); }
152 inline void Close() { this->f.reset(); }
154 inline operator FILE *()
156 assert(this->f !=
nullptr);
157 return this->f.get();
163 FileHandle(FILE *f) : f(f) { assert(this->f !=
nullptr); }
167template <>
constexpr std::optional<FileHandle>::operator bool() const noexcept = delete;
Helper for std::unique_ptr to use an arbitrary function as the deleter.
std::unique_ptr< T, DeleterFromFunc< Tfunc > > AutoRelease
Specialisation of std::unique_ptr for objects which must be deleted by calling a function.
static std::optional< FileHandle > Open(std::string_view filename, std::string_view mode)
Open an RAII file handle if possible.
static std::optional< FileHandle > Open(const std::string &filename, std::string_view mode)
Open an RAII file handle if possible.
Type (helpers) for enums.
#define DECLARE_INCREMENT_DECREMENT_OPERATORS(enum_type)
For some enums it is useful to have pre/post increment/decrement operators.
SaveLoadOperation
Operation performed on the file.
@ Check
Load file for checking and/or preview.
@ Save
File is being saved.
@ Load
File is being loaded.
DetailedFileType
Kinds of files in each AbstractFileType.
@ FiosDirect
Direct filename.
@ FiosDrive
A drive (letter) entry.
@ Invalid
Unknown or invalid file.
@ OldGameFile
Old save game or scenario file.
@ GameFile
Save game or scenario file.
@ FiosDirectory
A directory entry.
@ FiosParent
A parent directory entry.
Searchpath
Types of searchpaths OpenTTD might use.
@ Begin
The lowest valid value.
@ WorkingDir
Search in the working directory.
@ AutodownloadDir
Search within the autodownload directory.
@ ApplicationBundleDir
Search within the application bundle.
@ InstallationDir
Search in the installation directory.
@ AutodownloadPersonalDir
Search within the autodownload directory located in the personal directory.
@ SharedDir
Search in the shared directory, like 'Shared Files' under Windows.
@ BinaryDir
Search in the directory where the binary resides.
@ AutodownloadPersonalDirXdg
Search within the autodownload directory located in the personal directory (XDG variant).
@ PersonalDir
Search in the personal directory.
Subdirectory
The different kinds of subdirectories OpenTTD uses.
@ Base
Base directory for all subdirectories.
@ Autosave
Subdirectory of save for autosaves.
@ Lang
Subdirectory for all translation files.
@ NewGrf
Subdirectory for all NewGRFs.
@ Screenshot
Subdirectory for all screenshots.
@ GsLibrary
Subdirectory for all GS libraries.
@ Ai
Subdirectory for all AI files.
@ Gs
Subdirectory for all game scripts.
@ Docs
Subdirectory for documentation.
@ Baseset
Subdirectory for all base data (base sets, intro game).
@ OldData
Old subdirectory for the data.
@ AiLibrary
Subdirectory for all AI libraries.
@ OldGm
Old subdirectory for the music.
AbstractFileType
The different abstract types of files that the system knows about.
@ Savegame
old or new savegame
@ Invalid
Invalid or unknown file type.
@ Scenario
old or new scenario
@ Heightmap
heightmap file
Elements of a file system that are recognized.
DetailedFileType detailed
Detailed file type.
AbstractFileType abstract
Abstract file type.