|
OpenTTD Source
14.0-beta1
|
Go to the documentation of this file.
29 std::unique_ptr<char[]>
ReadFileToMem(
const std::string &filename,
size_t &lenp,
size_t maxsize);
34 extern std::vector<Searchpath> _valid_searchpaths;
44 uint
Scan(
const char *extension,
Subdirectory sd,
bool tars =
true,
bool recursive =
true);
45 uint
Scan(
const char *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;
95 DIR *opendir(
const wchar_t *path);
96 struct dirent *readdir(
DIR *d);
100 # include <sys/types.h>
113 return opendir(
OTTD2FS(path).c_str());
131 void operator()(FILE *f)
@ ALL
Scan for everything.
void FioFCloseFile(FILE *f)
Close a file in a safe way.
DIR * ttd_opendir(const char *path)
A wrapper around opendir() which will convert the string from OPENTTD encoding to that of the filesys...
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 ...
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.
void SanitizeFilename(std::string &filename)
Sanitizes a filename, i.e.
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.
virtual ~FileScanner()=default
Destruct the proper one...
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.
Mode
The mode of tar scanning.
std::string FioFindFullPath(Subdirectory subdir, const std::string &filename)
Find a path to the filename in one of the search directories.
std::wstring OTTD2FS(const std::string &name)
Convert from OpenTTD's encoding to a wide string.
const char * FiosGetScreenshotDir()
Get the directory for screenshots.