Definition in file fs.c.
#include "fs.h"
#include "options.h"
#include "pace.h"
#include "utils.h"
#include "logging.h"
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <stdarg.h>
#include <stdlib.h>
#include <ctype.h>
#include <dirent.h>
Go to the source code of this file.
Data Structures | |
struct | file |
used internally to find and open files More... | |
Defines | |
#define | NAMLEN(dirent) strlen((dirent)->d_name) |
see how do we call mkdir | |
#define | PATHSEP '/' |
path separator setup | |
Functions | |
int | create_save_dir (void) |
Create the savegame directory. | |
int | first_saved_game (struct ffblk *ffblk) |
void | fix_pathsep (char *name) |
gamedata & savedata access functions | |
char * | locate_file (const char *name, int type) |
Find and open file, if found return full path. | |
LOG_DEFAULT_CATEGORY (filesys) | |
int | next_saved_game (struct ffblk *ffblk) |
FILE * | open_gamedat (const char *name) |
FILE * | open_savedat (const char *name, const char *mode) |
int | remove_savedat (const char *name) |
static file | s_open_helper (const char *base, const char *name, const char *mode,...) |
try to open base/xxx/name for xxx = arg4 . | |
char * | slurp_gamedat (const char *name) |
FILE * | sOpen (const char *name, const char *mode, int type) |
static file | try_find_file (const char *name, const char *mode, int type) |
tries to find a file and open it | |
static FILE * | try_fopen (const char *fname, const char *mode) |
Variables | |
static DIR * | save_dir |
#define NAMLEN | ( | dirent | ) | strlen((dirent)->d_name) |
see how do we call mkdir
see how we get the length of a directory's name
Definition at line 64 of file fs.c.
Referenced by next_saved_game().
#define PATHSEP '/' |
int create_save_dir | ( | void | ) |
Create the savegame directory.
The directory will be created as defined in options.dir_savegame.
0 on success
Definition at line 367 of file fs.c.
Referenced by main(), and write_default_config().
int first_saved_game | ( | struct ffblk * | ffblk | ) |
void fix_pathsep | ( | char * | name | ) |
gamedata & savedata access functions
Definition at line 94 of file fs.c.
Referenced by fixpath_options(), remove_savedat(), and s_open_helper().
char* locate_file | ( | const char * | name, | |
int | type | |||
) |
Find and open file, if found return full path.
Caller is responsible for freeing the memory.
Definition at line 290 of file fs.c.
Referenced by av_setup().
LOG_DEFAULT_CATEGORY | ( | filesys | ) |
int next_saved_game | ( | struct ffblk * | ffblk | ) |
FILE* open_gamedat | ( | const char * | name | ) |
Definition at line 321 of file fs.c.
Referenced by main(), OpenAnim(), PlaySequence(), and slurp_gamedat().
FILE* open_savedat | ( | const char * | name, | |
const char * | mode | |||
) |
int remove_savedat | ( | const char * | name | ) |
Definition at line 302 of file fs.c.
Referenced by Draw_Mis_Stats(), EndOfTurnSave(), FileAccess(), HPurc(), Launch(), and MissionPast().
static file s_open_helper | ( | const char * | base, | |
const char * | name, | |||
const char * | mode, | |||
... | ||||
) | [static] |
try to open base/xxx/name for xxx = arg4 .
..
Definition at line 126 of file fs.c.
References fix_pathsep(), file::handle, file::path, try_fopen(), xmalloc(), and xrealloc().
Referenced by try_find_file().
char* slurp_gamedat | ( | const char * | name | ) |
FILE* sOpen | ( | const char * | name, | |
const char * | mode, | |||
int | type | |||
) |
Definition at line 275 of file fs.c.
Referenced by AbzFrame(), AI_Begin(), AstFaces(), AstSel(), BackIntel(), BChoice(), BigHardMe(), BudPict(), ClearRecord(), Credits(), DispBaby(), Display_ARROW(), DispVAB(), Draw_Mis_Stats(), Draw_NewEnd(), DrawControl(), DrawFuture(), DrawHPurc(), DrawPrefs(), DrawRD(), DrawRevText(), DrawRush(), DrawSpaceport(), DrawStatistics(), EditAst(), EndOfTurnSave(), EndPict(), FileAccess(), FileText(), find_replay(), frm_read_tbl(), FutureCheck(), GenerateTables(), GetFailStat(), GetMisType(), Help(), HistFile(), HModel(), Hospital(), HPurc(), LMPict(), load_audio_file(), Load_CIA_BUT(), Load_FUT_BUT(), Load_LenFlag(), Load_RD_BUT(), LoadNewsAnim(), LoserPict(), main(), MakeRecords(), MChoice(), MissionPast(), Moon(), music_load(), News(), NextTurn(), open_gamedat(), open_savedat(), OpenNews(), PadPict(), PatchMe(), PlaceEquip(), PlaySequence(), Port(), PortPal(), Prefs(), PresPict(), read_intro_images(), Records(), Replay(), RetFile(), REvent(), SafetyRecords(), SatDraw(), save_game(), SaveMail(), SelectBest(), SetEvents(), SetParameters(), ShowEvt(), SmHardMe(), SpotCrap(), TopSecret(), UpdateRecords(), VAB(), and WaveFlagSetup().
static file try_find_file | ( | const char * | name, | |
const char * | mode, | |||
int | type | |||
) | [static] |
tries to find a file and open it
The function knows about the relative position of certain filetypes. It retrieves the position savegamedir and gamedatadir from options.
name | Name of the file to open | |
mode | mode to file should be opened in | |
type | Type of the file eg. FT_SAVE, FT_DATA, ... |
Definition at line 198 of file fs.c.
References DEBUG2, game_options::dir_gamedata, game_options::dir_savegame, FT_AUDIO, FT_DATA, FT_IMAGE, FT_MIDI, FT_SAVE, FT_VIDEO, file::handle, options, s_open_helper(), and WARNING3.
Referenced by locate_file(), and sOpen().
static FILE* try_fopen | ( | const char * | fname, | |
const char * | mode | |||
) | [static] |
DIR* save_dir [static] |