#include <map>
#include <string>
#include "core/enum_type.hpp"
Go to the source code of this file.
Data Structures | |
struct | TarListEntry |
The define of a TarList. More... | |
struct | TarFileListEntry |
Defines | |
#define | FOR_ALL_SEARCHPATHS(sp) for (sp = SP_FIRST_DIR; sp < NUM_SEARCHPATHS; sp++) if (IsValidSearchPath(sp)) |
Iterator for all the search paths. | |
#define | FOR_ALL_TARS(tar) for (tar = _tar_filelist.begin(); tar != _tar_filelist.end(); tar++) |
Typedefs | |
typedef std::map< std::string, TarListEntry > | TarList |
typedef std::map< std::string, TarFileListEntry > | TarFileList |
typedef bool | FioTarFileListCallback (const char *filename, int size, void *userdata) |
Enumerations | |
enum | Subdirectory { BASE_DIR, SAVE_DIR, AUTOSAVE_DIR, SCENARIO_DIR, HEIGHTMAP_DIR, GM_DIR, DATA_DIR, LANG_DIR, NUM_SUBDIRS, NO_DIRECTORY } |
The different kinds of subdirectories OpenTTD uses. More... | |
enum | Searchpath { SP_FIRST_DIR, SP_WORKING_DIR = SP_FIRST_DIR, SP_PERSONAL_DIR, SP_SHARED_DIR, SP_BINARY_DIR, SP_INSTALLATION_DIR, SP_APPLICATION_BUNDLE_DIR, NUM_SEARCHPATHS } |
Types of searchpaths OpenTTD might use. More... | |
Functions | |
void | FioSeekTo (uint32 pos, int mode) |
void | FioSeekToFile (uint8 slot, uint32 pos) |
uint32 | FioGetPos () |
const char * | FioGetFilename (uint8 slot) |
byte | FioReadByte () |
uint16 | FioReadWord () |
uint32 | FioReadDword () |
void | FioCloseAll () |
void | FioOpenFile (int slot, const char *filename) |
void | FioReadBlock (void *ptr, uint size) |
void | FioSkipBytes (int n) |
void | FioCreateDirectory (const char *filename) |
Create a directory with the given name. | |
DECLARE_POSTFIX_INCREMENT (Searchpath) | |
static bool | IsValidSearchPath (Searchpath sp) |
Checks whether the given search path is a valid search path. | |
FILE * | FioTarFileList (const char *tar, const char *mode, size_t *filesize, FioTarFileListCallback *callback, void *userdata) |
void | FioFCloseFile (FILE *f) |
Close a file in a safe way. | |
FILE * | FioFOpenFile (const char *filename, const char *mode="rb", Subdirectory subdir=DATA_DIR, size_t *filesize=NULL) |
Opens OpenTTD files somewhere in a personal or global directory. | |
bool | FioCheckFileExists (const char *filename, Subdirectory subdir=DATA_DIR) |
Check whether the given file exists. | |
char * | FioGetFullPath (char *buf, size_t buflen, Searchpath sp, Subdirectory subdir, const char *filename) |
char * | FioFindFullPath (char *buf, size_t buflen, Subdirectory subdir, const char *filename) |
char * | FioAppendDirectory (char *buf, size_t buflen, Searchpath sp, Subdirectory subdir) |
char * | FioGetDirectory (char *buf, size_t buflen, Subdirectory subdir) |
static const char * | FioGetSubdirectory (Subdirectory subdir) |
void | SanitizeFilename (char *filename) |
Sanitizes a filename, i.e. | |
void | AppendPathSeparator (char *buf, size_t buflen) |
Appends, if necessary, the path separator character to the end of the string. | |
void | DeterminePaths (const char *exe) |
Acquire the base paths (personal dir and game data dir), fill all other paths (save dir, autosave dir etc) and make the save and scenario directories. | |
void * | ReadFileToMem (const char *filename, size_t *lenp, size_t maxsize) |
bool | FileExists (const char *filename) |
Variables | |
const char * | _searchpaths [NUM_SEARCHPATHS] |
The searchpaths OpenTTD could search through. | |
TarList | _tar_list |
TarFileList | _tar_filelist |
char * | _personal_dir |
custom directory for personal settings, saves, newgrf, etc. |
Definition in file fileio.h.
enum Searchpath |
Types of searchpaths OpenTTD might use.
enum Subdirectory |
The different kinds of subdirectories OpenTTD uses.
void AppendPathSeparator | ( | char * | buf, | |
size_t | buflen | |||
) |
Appends, if necessary, the path separator character to the end of the string.
It does not add the path separator to zero-sized strings.
buf | string to append the separator to | |
buflen | the length of the buf |
Definition at line 406 of file fileio.cpp.
Referenced by BuildWithFullPath(), and DetermineBasePaths().
void DeterminePaths | ( | const char * | exe | ) |
Acquire the base paths (personal dir and game data dir), fill all other paths (save dir, autosave dir etc) and make the save and scenario directories.
exe | the path from the current path to the executable |
Definition at line 711 of file fileio.cpp.
References AUTOSAVE_DIR, BASE_DIR, DetermineBasePaths(), FioCreateDirectory(), FOR_ALL_SEARCHPATHS, IsValidSearchPath(), SAVE_DIR, SP_BINARY_DIR, SP_INSTALLATION_DIR, SP_PERSONAL_DIR, SP_SHARED_DIR, and SP_WORKING_DIR.
bool FioCheckFileExists | ( | const char * | filename, | |
Subdirectory | subdir | |||
) |
Check whether the given file exists.
filename | the file to try for existance | |
subdir | the subdirectory to look in |
Definition at line 228 of file fileio.cpp.
References FioFCloseFile(), and FioFOpenFile().
Referenced by DeterminePalette().
void FioCreateDirectory | ( | const char * | name | ) |
Create a directory with the given name.
name | the new name of the directory |
Definition at line 379 of file fileio.cpp.
References OTTD2FS().
Referenced by DeterminePaths().
static bool IsValidSearchPath | ( | Searchpath | sp | ) | [inline, static] |
Checks whether the given search path is a valid search path.
sp | the search path to check |
Definition at line 88 of file fileio.h.
References _searchpaths.
Referenced by DeterminePaths().
void SanitizeFilename | ( | char * | filename | ) |
Sanitizes a filename, i.e.
removes all illegal characters from it.
filename | the "\0" terminated filename |
Definition at line 774 of file fileio.cpp.
const char* _searchpaths[NUM_SEARCHPATHS] |
The searchpaths OpenTTD could search through.
At least one of the slots has to be filled with a path. NULL paths tell that there is no such path for the current operating system.
Definition at line 218 of file fileio.cpp.
Referenced by IsValidSearchPath().