OpenTTD Source
12.0-beta2
|
Go to the documentation of this file.
31 std::unique_ptr<char[]>
ReadFileToMem(
const std::string &filename,
size_t &lenp,
size_t maxsize);
36 extern std::vector<Searchpath> _valid_searchpaths;
46 uint
Scan(
const char *extension,
Subdirectory sd,
bool tars =
true,
bool recursive =
true);
47 uint
Scan(
const char *extension,
const char *directory,
bool recursive =
true);
57 virtual bool AddFile(
const std::string &filename,
size_t basepath_length,
const std::string &tar_filename) = 0;
75 bool AddFile(
const std::string &filename,
size_t basepath_length,
const std::string &tar_filename = {})
override;
97 DIR *opendir(
const wchar_t *path);
98 struct dirent *readdir(
DIR *d);
102 # include <sys/types.h>
115 return opendir(
OTTD2FS(path).c_str());
133 void operator()(FILE *f)
@ ALL
Scan for everything.
void FioFCloseFile(FILE *f)
Close a file in a safe way.
uint DoScan(Subdirectory sd)
Perform the scanning of a particular subdirectory.
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 ...
void SanitizeFilename(char *filename)
Sanitizes a filename, i.e.
virtual ~FileScanner()
Destruct the proper one...
std::string FioFindFullPath(Subdirectory subdir, const char *filename)
Find a path to the filename in one of the search directories.
Searchpath
Types of searchpaths OpenTTD might use.
uint Scan(const char *extension, Subdirectory sd, bool tars=true, bool recursive=true)
Scan for files with the given extension in the given search path.
bool FioCheckFileExists(const std::string &filename, Subdirectory subdir)
Check whether the given file exists.
void AppendPathSeparator(std::string &buf)
Appends, if necessary, the path separator character to the end of the string.
Auto-close a file upon scope exit.
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.
@ NEWGRF
Scan for non-base sets.
std::unique_ptr< char[]> ReadFileToMem(const std::string &filename, size_t &lenp, size_t maxsize)
Load a file into memory.
@ GAME
Scan for game scripts.
bool AddFile(const std::string &filename, size_t basepath_length, const std::string &tar_filename={}) override
Add a file with the given filename.
bool FileExists(const std::string &filename)
Test whether the given filename exists.
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,...
@ SCENARIO
Scan for scenarios and heightmaps.
std::string _personal_dir
custom directory for personal settings, saves, newgrf, etc.
Subdirectory
The different kinds of subdirectories OpenTTD uses.
DECLARE_ENUM_AS_BIT_SET(GenderEthnicity) enum CompanyManagerFaceVariable
Bitgroups of the CompanyManagerFace variable.
Helper to manage a FILE with a std::unique_ptr.
Helper for scanning for files with tar as extension.
bool ExtractTar(const std::string &tar_filename, Subdirectory subdir)
Extract the tar with the given filename in the directory where the tar resides.
Helper for scanning for files with a given name.
@ BASESET
Scan for base sets.
FILE * 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.
static DIR * ttd_opendir(const char *path)
A wrapper around opendir() which will convert the string from OPENTTD encoding to that of the filesys...
Mode
The mode of tar scanning.
std::wstring OTTD2FS(const std::string &name)
Convert from OpenTTD's encoding to a wide string.
const char * FiosGetScreenshotDir()
Get the directory for screenshots.