66 #define MAKE_FIOS_TYPE(abstract, detailed) ((abstract) | ((detailed) << FT_NUMBITS))
160 static std::optional<FileHandle> Open(
const std::string &filename,
const std::string &mode);
162 inline void Close() { this->f.reset(); }
164 inline operator FILE *()
166 assert(this->f !=
nullptr);
167 return this->f.get();
173 void operator ()(FILE *f)
175 if (f !=
nullptr) fclose(f);
179 std::unique_ptr<FILE, FileDeleter> f;
181 FileHandle(FILE *f) : f(f) { assert(this->f !=
nullptr); }
185 template <> constexpr std::optional<FileHandle>::operator bool() const noexcept = delete;
Type (helpers) for enums.
#define DECLARE_POSTFIX_INCREMENT(enum_type)
Some enums need to have allowed incrementing (i.e.
DetailedFileType GetDetailedFileType(FiosType fios_type)
Extract the detailed file type from a FiosType.
AbstractFileType GetAbstractFileType(FiosType fios_type)
Extract the abstract file type from a FiosType.
AbstractFileType
The different abstract types of files that the system knows about.
@ FT_SCENARIO
old or new scenario
@ FT_HEIGHTMAP
heightmap file
@ FT_SAVEGAME
old or new savegame
@ FT_NUMBITS
Number of bits required for storing a AbstractFileType value.
@ FT_INVALID
Invalid or unknown file type.
@ FT_TOWN_DATA
town data file
@ FT_MASK
Bitmask for extracting an abstract file type.
FiosType
Elements of a file system that are recognized.
SaveLoadOperation
Operation performed on the file.
@ SLO_CHECK
Load file for checking and/or preview.
@ SLO_SAVE
File is being saved.
@ SLO_LOAD
File is being loaded.
@ SLO_INVALID
Unknown file operation.
#define MAKE_FIOS_TYPE(abstract, detailed)
Construct an enum value for FiosType as a combination of an abstract and a detailed file type.
DetailedFileType
Kinds of files in each AbstractFileType.
@ DFT_FIOS_DRIVE
A drive (letter) entry.
@ DFT_GAME_FILE
Save game or scenario file.
@ DFT_HEIGHTMAP_BMP
BMP file.
@ DFT_HEIGHTMAP_PNG
PNG file.
@ DFT_FIOS_DIR
A directory entry.
@ DFT_FIOS_PARENT
A parent directory entry.
@ DFT_INVALID
Unknown or invalid file.
@ DFT_FIOS_DIRECT
Direct filename.
@ DFT_TOWN_DATA_JSON
JSON file.
@ DFT_END
End of this enum. Supports a compile time size check against _fios_colours in fios_gui....
@ DFT_OLD_GAME_FILE
Old save game or scenario file.
Searchpath
Types of searchpaths OpenTTD might use.
@ SP_SHARED_DIR
Search in the shared directory, like 'Shared Files' under Windows.
@ SP_INSTALLATION_DIR
Search in the installation directory.
@ SP_AUTODOWNLOAD_PERSONAL_DIR_XDG
Search within the autodownload directory located in the personal directory (XDG variant)
@ SP_BINARY_DIR
Search in the directory where the binary resides.
@ SP_AUTODOWNLOAD_PERSONAL_DIR
Search within the autodownload directory located in the personal directory.
@ SP_PERSONAL_DIR
Search in the personal directory.
@ SP_WORKING_DIR
Search in the working directory.
@ SP_APPLICATION_BUNDLE_DIR
Search within the application bundle.
@ SP_AUTODOWNLOAD_DIR
Search within the autodownload directory.
Subdirectory
The different kinds of subdirectories OpenTTD uses.
@ OLD_DATA_DIR
Old subdirectory for the data.
@ NO_DIRECTORY
A path without any base directory.
@ AI_LIBRARY_DIR
Subdirectory for all AI libraries.
@ SCREENSHOT_DIR
Subdirectory for all screenshots.
@ SOCIAL_INTEGRATION_DIR
Subdirectory for all social integration plugins.
@ GAME_LIBRARY_DIR
Subdirectory for all GS libraries.
@ AI_DIR
Subdirectory for all AI files.
@ OLD_GM_DIR
Old subdirectory for the music.
@ SCENARIO_DIR
Base directory for all scenarios.
@ BASE_DIR
Base directory for all subdirectories.
@ SAVE_DIR
Base directory for all savegames.
@ NUM_SUBDIRS
Number of subdirectories.
@ HEIGHTMAP_DIR
Subdirectory of scenario for heightmaps.
@ NEWGRF_DIR
Subdirectory for all NewGRFs.
@ AUTOSAVE_DIR
Subdirectory of save for autosaves.
@ LANG_DIR
Subdirectory for all translation files.
@ BASESET_DIR
Subdirectory for all base data (base sets, intro game)
@ GAME_DIR
Subdirectory for all game scripts.
Helper to close a FILE * with a std::unique_ptr.