Go to the documentation of this file.
37 #define FOR_ALL_SEARCHPATHS(sp) for (sp = SP_FIRST_DIR; sp < NUM_SEARCHPATHS; sp++) if (IsValidSearchPath(sp))
52 std::unique_ptr<char>
ReadFileToMem(
const std::string &filename,
size_t &lenp,
size_t maxsize);
66 uint
Scan(
const char *extension,
Subdirectory sd,
bool tars =
true,
bool recursive =
true);
67 uint
Scan(
const char *extension,
const char *directory,
bool recursive =
true);
77 virtual bool AddFile(
const std::string &filename,
size_t basepath_length,
const std::string &tar_filename) = 0;
95 bool AddFile(
const std::string &filename,
size_t basepath_length,
const std::string &tar_filename = {})
override;
117 DIR *opendir(
const wchar_t *path);
118 struct dirent *readdir(
DIR *d);
119 int closedir(
DIR *d);
122 # include <sys/types.h>
153 void operator()(FILE *f)
@ ALL
Scan for everything.
void FioCloseAll()
Close all slotted open files.
void FioFCloseFile(FILE *f)
Close a file in a safe way.
uint32 FioReadDword()
Read a double word (32 bits) from the file (in low endian format).
uint16 FioReadWord()
Read a word (16 bits) from the file (in low endian format).
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.
std::unique_ptr< char > ReadFileToMem(const std::string &filename, size_t &lenp, size_t maxsize)
Load a file into memory.
bool FioCheckFileExists(const std::string &filename, Subdirectory subdir)
Check whether the given file exists.
void FioOpenFile(int slot, const std::string &filename, Subdirectory subdir)
Open a slotted file.
byte FioReadByte()
Read a byte from the file.
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.
void FioReadBlock(void *ptr, size_t size)
Read a block.
Subdirectory subdir
The current sub directory we are searching through.
@ NEWGRF
Scan for non-base sets.
size_t FioGetPos()
Get position in the current file.
@ 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.
void FioSkipBytes(int n)
Skip n bytes ahead in the file.
bool FileExists(const std::string &filename)
Test whether the given filename exists.
@ SCENARIO
Scan for scenarios and heightmaps.
void DeterminePaths(const char *exe)
Acquire the base paths (personal dir and game data dir), fill all other paths (save dir,...
void FioSeekTo(size_t pos, int mode)
Seek in the current file.
bool IsValidSearchPath(Searchpath sp)
Checks whether the given search path is a valid search path.
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.
const char * FioGetFilename(uint8 slot)
Get the filename associated with a slot.
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.
void FioSeekToFile(uint8 slot, size_t pos)
Switch to a different file and seek to a position.
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.
const wchar_t * OTTD2FS(const char *name, bool console_cp)
Convert from OpenTTD's encoding to wide characters.
const char * FiosGetScreenshotDir()
Get the directory for screenshots.