49 #define FOR_ALL_SEARCHPATHS(sp) for (sp = SP_FIRST_DIR; sp < NUM_SEARCHPATHS; sp++) if (IsValidSearchPath(sp)) 54 char *FioGetFullPath(
char *buf,
const char *last,
Searchpath sp,
Subdirectory subdir,
const char *filename);
57 char *FioGetDirectory(
char *buf,
const char *last,
Subdirectory subdir);
64 void *
ReadFileToMem(
const char *filename,
size_t *lenp,
size_t maxsize);
67 void FioTarAddLink(
const char *src,
const char *dest,
Subdirectory subdir);
80 uint
Scan(
const char *extension,
Subdirectory sd,
bool tars =
true,
bool recursive =
true);
81 uint
Scan(
const char *extension,
const char *directory,
bool recursive =
true);
91 virtual bool AddFile(
const char *filename,
size_t basepath_length,
const char *tar_filename) = 0;
106 ALL = BASESET | NEWGRF |
AI | SCENARIO | GAME,
109 bool AddFile(
const char *filename,
size_t basepath_length,
const char *tar_filename = NULL);
131 DIR *opendir(
const TCHAR *path);
132 struct dirent *readdir(
DIR *d);
133 int closedir(
DIR *d);
136 # include <sys/types.h> DECLARE_ENUM_AS_BIT_SET(GenderEthnicity) enum CompanyManagerFaceVariable
Bitgroups of the CompanyManagerFace variable.
Subdirectory
The different kinds of subdirectories OpenTTD uses.
const char * _personal_dir
custom directory for personal settings, saves, newgrf, etc.
bool FioCheckFileExists(const char *filename, Subdirectory subdir)
Check whether the given file exists.
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.
virtual ~FileScanner()
Destruct the proper one...
Helper for scanning for files with tar as extension.
bool AppendPathSeparator(char *buf, const char *last)
Appends, if necessary, the path separator character to the end of the string.
uint16 FioReadWord()
Read a word (16 bits) from the file (in low endian format).
Searchpath
Types of searchpaths OpenTTD might use.
Type (helpers) for enums.
size_t FioGetPos()
Get position in the current file.
virtual bool AddFile(const char *filename, size_t basepath_length, const char *tar_filename)=0
Add a file with the given filename.
Helper for scanning for files with a given name.
void FioOpenFile(int slot, const char *filename, Subdirectory subdir)
Open a slotted file.
Types for Standard In/Out file operations.
void FioReadBlock(void *ptr, size_t size)
Read a block.
void FioSeekTo(size_t pos, int mode)
Seek in the current file.
void DeterminePaths(const char *exe)
Acquire the base paths (personal dir and game data dir), fill all other paths (save dir...
void FioCloseAll()
Close all slotted open files.
void FioSeekToFile(uint8 slot, size_t pos)
Switch to a different file and seek to a position.
uint32 FioReadDword()
Read a double word (32 bits) from the file (in low endian format).
const TCHAR * OTTD2FS(const char *name, bool console_cp)
Convert from OpenTTD's encoding to that of the local environment.
void SanitizeFilename(char *filename)
Sanitizes a filename, i.e.
char * FioFindFullPath(char *buf, const char *last, Subdirectory subdir, const char *filename)
Find a path to the filename in one of the search directories.
const char * _searchpaths[NUM_SEARCHPATHS]
The search paths OpenTTD could search through.
bool ExtractTar(const char *tar_filename, Subdirectory subdir)
Extract the tar with the given filename in the directory where the tar resides.
Subdirectory subdir
The current sub directory we are searching through.
Mode
The mode of tar scanning.
bool FileExists(const char *filename)
Test whether the given filename exists.
void * ReadFileToMem(const char *filename, size_t *lenp, size_t maxsize)
Load a file into memory.
static DIR * ttd_opendir(const char *path)
A wrapper around opendir() which will convert the string from OPENTTD encoding to that of the filesys...
void FioSkipBytes(int n)
Skip n bytes ahead in the file.
const char * FiosGetScreenshotDir()
Get the directory for screenshots.
static bool IsValidSearchPath(Searchpath sp)
Checks whether the given search path is a valid search path.
void FioFCloseFile(FILE *f)
Close a file in a safe way.
FILE * FioFOpenFile(const char *filename, const char *mode, Subdirectory subdir, size_t *filesize=NULL)
Opens a OpenTTD file somewhere in a personal or global directory.
const char * FioGetFilename(uint8 slot)
Get the filename associated with a slot.
const char * FioTarFirstDir(const char *tarname, Subdirectory subdir)
Find the first directory in a tar archive.
byte FioReadByte()
Read a byte from the file.