# fios.h File Reference

Declarations for savegames operations. More...

`#include "strings_type.h"`
`#include "core/smallvec_type.hpp"`

Go to the source code of this file.

## Data Structures

struct | FiosItem
struct | SmallFiosItem

## Enumerations

enum | { CONFIG_SLOT = 0, SOUND_SLOT = 1, FIRST_GRF_SLOT = 2, LAST_GRF_SLOT = 63, MAX_FILE_SLOTS = 64 }
enum | SaveLoadDialogMode { SLD_LOAD_GAME, SLD_LOAD_SCENARIO, SLD_SAVE_GAME, SLD_SAVE_SCENARIO, SLD_LOAD_HEIGHTMAP, SLD_NEW_GAME }
enum | FileType { FT_NONE, FT_SAVEGAME, FT_SCENARIO, FT_HEIGHTMAP }
enum | FiosType { FIOS_TYPE_DRIVE, FIOS_TYPE_PARENT, FIOS_TYPE_DIR, FIOS_TYPE_FILE, FIOS_TYPE_OLDFILE, FIOS_TYPE_SCENARIO, FIOS_TYPE_OLD_SCENARIO, FIOS_TYPE_DIRECT, FIOS_TYPE_PNG, FIOS_TYPE_BMP, FIOS_TYPE_INVALID = 255 }
enum | { SORT_ASCENDING = 0, SORT_DESCENDING = 1, SORT_BY_DATE = 0, SORT_BY_NAME = 2 }

## Functions

void | ShowSaveLoadDialog (SaveLoadDialogMode mode)
void | FiosGetSavegameList (SaveLoadDialogMode mode)
| Get a list of savegames.
void | FiosGetScenarioList (SaveLoadDialogMode mode)
| Get a list of scenarios.
void | FiosGetHeightmapList (SaveLoadDialogMode mode)
void | FiosFreeSavegameList ()
| Clear the list.
const char * | FiosBrowseTo (const FiosItem *item)
StringID | FiosGetDescText (const char **path, uint64 *total_free)
| Get descriptive texts.
bool | FiosDelete (const char *name)
void | FiosMakeSavegameName (char *buf, const char *name, size_t size)
FiosType | FiosGetSavegameListCallback (SaveLoadDialogMode mode, const char *file, const char *ext, char *title, const char *last)
| Callback for FiosGetFileList.
int CDECL | compare_FiosItems (const void *a, const void *b)
| Compare two FiosItem's.

## Variables

SmallVector< FiosItem, 32 > | _fios_items
| defined in fios.cpp
SmallFiosItem | _file_to_saveload
SaveLoadDialogMode | _saveload_mode
| defined in misc_gui.cpp
byte | _savegame_sort_order

## Detailed Description

Declarations for savegames operations.

Definition in file fios.h.

## Enumeration Type Documentation

anonymous enum

Enumerator:

  CONFIG_SLOT | Slot used for the GRF scanning and such. This slot cannot be reused as it will otherwise cause issues when pressing "rescan directories". It can furthermore not be larger than LAST_GRF_SLOT as that complicates the testing for "too much NewGRFs".
  SOUND_SLOT | Slot for the sound.
  FIRST_GRF_SLOT | First slot useable for (New)GRFs used during the game.
  LAST_GRF_SLOT | Last slot useable for (New)GRFs used during the game.
  MAX_FILE_SLOTS | Maximum number of slots.

Definition at line 11 of file fios.h.

enum FileType

Enumerator:

  FT_NONE | nothing to do
  FT_SAVEGAME | old or new savegame
  FT_SCENARIO | old or new scenario
  FT_HEIGHTMAP | heightmap file

Definition at line 39 of file fios.h.

## Function Documentation

int CDECL compare_FiosItems | ( | const void * | a,
|  | const void * | b |
| ) |  |  |

Compare two FiosItem's.

Used with qsort when sorting the file list.

Parameters:

  | a | A pointer to the first FiosItem to compare.
  | b | A pointer to the second FiosItem to compare.

Returns:
  -1, 0 or 1, depending on how the two items should be sorted.

Definition at line 44 of file fios.cpp.

Referenced by FiosGetFileList().

StringID FiosGetDescText | ( | const char ** | path,
|  | uint64 * | total_free |
| ) |  |  |

Get descriptive texts.

Returns the path and free space left on the device

Parameters:

  | path | string describing the path
  | total_free | total free space in megabytes, optional (can be NULL)

Returns:
  StringID describing the path (free space or failure)

Definition at line 74 of file fios.cpp.

void FiosGetSavegameList | ( | SaveLoadDialogMode | mode | ) |

Get a list of savegames.

Parameters:

  | mode | Save/load mode.

Returns:
  A pointer to an array of FiosItem representing all the files to be shown in the save/load dialog.

See also:
  FiosGetFileList

Definition at line 388 of file fios.cpp.

References FiosGetFileList(), FiosGetSavegameListCallback(), NO_DIRECTORY, and SAVE_DIR.

FiosType FiosGetSavegameListCallback | ( | SaveLoadDialogMode | mode,
|  | const char * | file,
|  | const char * | ext,
|  | char * | title,
|  | const char * | last |
| ) |  |  |

Callback for FiosGetFileList.

It tells if a file is a savegame or not.

Parameters:

  | mode | Save/load mode.
  | file | Name of the file to check.
  | ext | A pointer to the extension identifier inside file
  | title | Buffer if a callback wants to lookup the title of the file; NULL to skip the lookup
  | last | Last available byte in buffer (to prevent buffer overflows); not used when title == NULL

Returns:
  a FIOS_TYPE_* type of the found file, FIOS_TYPE_INVALID if not a savegame

See also:
  FiosGetFileList

  FiosGetSavegameList

Definition at line 359 of file fios.cpp.

References GetFileTitle().

Referenced by FiosGetSavegameList().

void FiosGetScenarioList | ( | SaveLoadDialogMode | mode | ) |

Get a list of scenarios.

Parameters:

  | mode | Save/load mode.

Returns:
  A pointer to an array of FiosItem representing all the files to be shown in the save/load dialog.

See also:
  FiosGetFileList

Definition at line 440 of file fios.cpp.

References FiosGetFileList(), FiosGetScenarioListCallback(), NO_DIRECTORY, and SCENARIO_DIR.