16std::optional<FileHandle>
FioFOpenFile(
const std::string &filename,
const char *mode,
Subdirectory subdir,
size_t *filesize =
nullptr);
22bool FioRemove(
const std::string &filename);
29std::unique_ptr<char[]>
ReadFileToMem(
const std::string &filename,
size_t &lenp,
size_t maxsize);
34extern std::vector<Searchpath> _valid_searchpaths;
44 uint
Scan(std::string_view extension,
Subdirectory sd,
bool tars =
true,
bool recursive =
true);
45 uint
Scan(std::string_view extension,
const std::string &directory,
bool recursive =
true);
55 virtual bool AddFile(
const std::string &filename,
size_t basepath_length,
const std::string &tar_filename) = 0;
73 bool AddFile(
const std::string &filename,
size_t basepath_length,
const std::string &tar_filename = {})
override;
Helper for scanning for files with a given name.
uint Scan(std::string_view extension, Subdirectory sd, bool tars=true, bool recursive=true)
Scan for files with the given extension in the given search path.
virtual ~FileScanner()=default
Destruct the proper one...
virtual bool AddFile(const std::string &filename, size_t basepath_length, const std::string &tar_filename)=0
Add a file with the given filename.
Subdirectory subdir
The current sub directory we are searching through.
Helper for scanning for files with tar as extension.
uint DoScan(Subdirectory sd)
Perform the scanning of a particular subdirectory.
Mode
The mode of tar scanning.
@ NEWGRF
Scan for non-base sets.
@ BASESET
Scan for base sets.
@ GAME
Scan for game scripts.
@ SCENARIO
Scan for scenarios and heightmaps.
@ ALL
Scan for everything.
bool AddFile(const std::string &filename, size_t basepath_length, const std::string &tar_filename={}) override
Add a file with the given filename.
Type (helpers) for enums.
#define DECLARE_ENUM_AS_BIT_SET(enum_type)
Operators to allow to work with enum as with type safe bit set in C++.
std::string FioFindFullPath(Subdirectory subdir, const std::string &filename)
Find a path to the filename in one of the search directories.
bool ExtractTar(const std::string &tar_filename, Subdirectory subdir)
Extract the tar with the given filename in the directory where the tar resides.
void DeterminePaths(const char *exe, bool only_local_path)
Acquire the base paths (personal dir and game data dir), fill all other paths (save dir,...
bool FioRemove(const std::string &filename)
Remove a file.
void SanitizeFilename(std::string &filename)
Sanitizes a filename, i.e.
void AppendPathSeparator(std::string &buf)
Appends, if necessary, the path separator character to the end of the string.
std::string _personal_dir
custom directory for personal settings, saves, newgrf, etc.
bool FioCheckFileExists(const std::string &filename, Subdirectory subdir)
Check whether the given file exists.
void FioCreateDirectory(const std::string &name)
Create a directory with the given name If the parent directory does not exist, it will try to create ...
std::optional< FileHandle > FioFOpenFile(const std::string &filename, const char *mode, Subdirectory subdir, size_t *filesize=nullptr)
Opens a OpenTTD file somewhere in a personal or global directory.
bool FileExists(const std::string &filename)
Test whether the given filename exists.
const char * FiosGetScreenshotDir()
Get the directory for screenshots.
std::unique_ptr< char[]> ReadFileToMem(const std::string &filename, size_t &lenp, size_t maxsize)
Load a file into memory.
Types for Standard In/Out file operations.
Searchpath
Types of searchpaths OpenTTD might use.
Subdirectory
The different kinds of subdirectories OpenTTD uses.