src/fios.h
author belugas
Fri, 28 Dec 2007 04:20:56 +0000
changeset 8648 daa3c9e931ab
parent 8647 0709611186e0
child 8760 ce0891c412ce
permissions -rw-r--r--
(svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
This will not (yet) be true if you are loading a scenario with the "-g" command line option.
4218
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
     1
/* $Id$ */
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
     2
6505
abcb0580d976 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6414
diff changeset
     3
/** @file fios.h Declarations for savegames operations */
abcb0580d976 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6414
diff changeset
     4
4218
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
     5
#ifndef FIOS_H
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
     6
#define FIOS_H
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
     7
8301
47e8f031a6ab (svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium
parents: 6577
diff changeset
     8
enum {
47e8f031a6ab (svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium
parents: 6577
diff changeset
     9
	/**
47e8f031a6ab (svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium
parents: 6577
diff changeset
    10
	 * Slot used for the GRF scanning and such. This slot cannot be reused
47e8f031a6ab (svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium
parents: 6577
diff changeset
    11
	 * as it will otherwise cause issues when pressing "rescan directories".
47e8f031a6ab (svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium
parents: 6577
diff changeset
    12
	 * It can furthermore not be larger than LAST_GRF_SLOT as that complicates
47e8f031a6ab (svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium
parents: 6577
diff changeset
    13
	 * the testing for "too much NewGRFs".
47e8f031a6ab (svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium
parents: 6577
diff changeset
    14
	 */
47e8f031a6ab (svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium
parents: 6577
diff changeset
    15
	CONFIG_SLOT    =  0,
47e8f031a6ab (svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium
parents: 6577
diff changeset
    16
	/** Slot for the sound. */
47e8f031a6ab (svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium
parents: 6577
diff changeset
    17
	SOUND_SLOT     =  1,
47e8f031a6ab (svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium
parents: 6577
diff changeset
    18
	/** First slot useable for (New)GRFs used during the game. */
47e8f031a6ab (svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium
parents: 6577
diff changeset
    19
	FIRST_GRF_SLOT =  2,
47e8f031a6ab (svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium
parents: 6577
diff changeset
    20
	/** Last slot useable for (New)GRFs used during the game. */
47e8f031a6ab (svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium
parents: 6577
diff changeset
    21
	LAST_GRF_SLOT  = 63,
47e8f031a6ab (svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium
parents: 6577
diff changeset
    22
	/** Maximum number of slots. */
47e8f031a6ab (svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium
parents: 6577
diff changeset
    23
	MAX_FILE_SLOTS = 64
47e8f031a6ab (svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium
parents: 6577
diff changeset
    24
};
47e8f031a6ab (svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium
parents: 6577
diff changeset
    25
8645
83500ad80b08 (svn r11711) -Codechange: Name the Save Load Dialog Mode enum
belugas
parents: 8301
diff changeset
    26
enum SaveLoadDialogMode{
83500ad80b08 (svn r11711) -Codechange: Name the Save Load Dialog Mode enum
belugas
parents: 8301
diff changeset
    27
	SLD_LOAD_GAME,
83500ad80b08 (svn r11711) -Codechange: Name the Save Load Dialog Mode enum
belugas
parents: 8301
diff changeset
    28
	SLD_LOAD_SCENARIO,
83500ad80b08 (svn r11711) -Codechange: Name the Save Load Dialog Mode enum
belugas
parents: 8301
diff changeset
    29
	SLD_SAVE_GAME,
83500ad80b08 (svn r11711) -Codechange: Name the Save Load Dialog Mode enum
belugas
parents: 8301
diff changeset
    30
	SLD_SAVE_SCENARIO,
83500ad80b08 (svn r11711) -Codechange: Name the Save Load Dialog Mode enum
belugas
parents: 8301
diff changeset
    31
	SLD_LOAD_HEIGHTMAP,
83500ad80b08 (svn r11711) -Codechange: Name the Save Load Dialog Mode enum
belugas
parents: 8301
diff changeset
    32
	SLD_NEW_GAME,
83500ad80b08 (svn r11711) -Codechange: Name the Save Load Dialog Mode enum
belugas
parents: 8301
diff changeset
    33
};
83500ad80b08 (svn r11711) -Codechange: Name the Save Load Dialog Mode enum
belugas
parents: 8301
diff changeset
    34
8648
daa3c9e931ab (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas
parents: 8647
diff changeset
    35
/* The different types of files been handled by the system */
daa3c9e931ab (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas
parents: 8647
diff changeset
    36
enum FileType {
daa3c9e931ab (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas
parents: 8647
diff changeset
    37
	FT_NONE,      ///< nothing to do
daa3c9e931ab (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas
parents: 8647
diff changeset
    38
	FT_SAVEGAME,  ///< old or new savegame
daa3c9e931ab (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas
parents: 8647
diff changeset
    39
	FT_SCENARIO,  ///< old or new scenario
daa3c9e931ab (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas
parents: 8647
diff changeset
    40
	FT_HEIGHTMAP, ///< heightmap file
daa3c9e931ab (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas
parents: 8647
diff changeset
    41
};
daa3c9e931ab (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas
parents: 8647
diff changeset
    42
4223
0f9535dda7ed (svn r5767) - Cleanup: Improve upon the header file mess regarding fios. Move all relevant types from hal.h into fios.h, eliminate the unneccessary passing of a global variable, and extern variables in header files (declare in fios.c and misc_gui.c
Darkvater
parents: 4218
diff changeset
    43
enum {
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
    44
	FIOS_TYPE_DRIVE        =   0,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
    45
	FIOS_TYPE_PARENT       =   1,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
    46
	FIOS_TYPE_DIR          =   2,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
    47
	FIOS_TYPE_FILE         =   3,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
    48
	FIOS_TYPE_OLDFILE      =   4,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
    49
	FIOS_TYPE_SCENARIO     =   5,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
    50
	FIOS_TYPE_OLD_SCENARIO =   6,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
    51
	FIOS_TYPE_DIRECT       =   7,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
    52
	FIOS_TYPE_PNG          =   8,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
    53
	FIOS_TYPE_BMP          =   9,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
    54
	FIOS_TYPE_INVALID      = 255,
4223
0f9535dda7ed (svn r5767) - Cleanup: Improve upon the header file mess regarding fios. Move all relevant types from hal.h into fios.h, eliminate the unneccessary passing of a global variable, and extern variables in header files (declare in fios.c and misc_gui.c
Darkvater
parents: 4218
diff changeset
    55
};
0f9535dda7ed (svn r5767) - Cleanup: Improve upon the header file mess regarding fios. Move all relevant types from hal.h into fios.h, eliminate the unneccessary passing of a global variable, and extern variables in header files (declare in fios.c and misc_gui.c
Darkvater
parents: 4218
diff changeset
    56
8647
0709611186e0 (svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas
parents: 8645
diff changeset
    57
/* Deals with finding savegames */
0709611186e0 (svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas
parents: 8645
diff changeset
    58
struct FiosItem {
0709611186e0 (svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas
parents: 8645
diff changeset
    59
	byte type;
0709611186e0 (svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas
parents: 8645
diff changeset
    60
	uint64 mtime;
0709611186e0 (svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas
parents: 8645
diff changeset
    61
	char title[64];
0709611186e0 (svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas
parents: 8645
diff changeset
    62
	char name[256 - 12 - 64];
0709611186e0 (svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas
parents: 8645
diff changeset
    63
};
0709611186e0 (svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas
parents: 8645
diff changeset
    64
0709611186e0 (svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas
parents: 8645
diff changeset
    65
/* Deals with the type of the savegame, independent of extension */
0709611186e0 (svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas
parents: 8645
diff changeset
    66
struct SmallFiosItem {
0709611186e0 (svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas
parents: 8645
diff changeset
    67
	int mode;             ///< savegame/scenario type (old, new)
8648
daa3c9e931ab (svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas
parents: 8647
diff changeset
    68
	FileType filetype;    ///< what type of file are we dealing with
8647
0709611186e0 (svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas
parents: 8645
diff changeset
    69
	char name[MAX_PATH];  ///< name
0709611186e0 (svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas
parents: 8645
diff changeset
    70
	char title[255];      ///< internal name of the game
0709611186e0 (svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas
parents: 8645
diff changeset
    71
};
0709611186e0 (svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas
parents: 8645
diff changeset
    72
4223
0f9535dda7ed (svn r5767) - Cleanup: Improve upon the header file mess regarding fios. Move all relevant types from hal.h into fios.h, eliminate the unneccessary passing of a global variable, and extern variables in header files (declare in fios.c and misc_gui.c
Darkvater
parents: 4218
diff changeset
    73
/* Variables to display file lists */
6505
abcb0580d976 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6414
diff changeset
    74
extern FiosItem *_fios_list; ///< defined in misc_gui.cpp
abcb0580d976 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6414
diff changeset
    75
extern int _fios_num;        ///< defined in fios.cpp, read_only version of _fios_count
8647
0709611186e0 (svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas
parents: 8645
diff changeset
    76
extern SmallFiosItem _file_to_saveload;
8645
83500ad80b08 (svn r11711) -Codechange: Name the Save Load Dialog Mode enum
belugas
parents: 8301
diff changeset
    77
extern SaveLoadDialogMode _saveload_mode;   ///< defined in misc_gui.cpp
83500ad80b08 (svn r11711) -Codechange: Name the Save Load Dialog Mode enum
belugas
parents: 8301
diff changeset
    78
83500ad80b08 (svn r11711) -Codechange: Name the Save Load Dialog Mode enum
belugas
parents: 8301
diff changeset
    79
/* Launch save/load dialog */
83500ad80b08 (svn r11711) -Codechange: Name the Save Load Dialog Mode enum
belugas
parents: 8301
diff changeset
    80
void ShowSaveLoadDialog(SaveLoadDialogMode mode);
4223
0f9535dda7ed (svn r5767) - Cleanup: Improve upon the header file mess regarding fios. Move all relevant types from hal.h into fios.h, eliminate the unneccessary passing of a global variable, and extern variables in header files (declare in fios.c and misc_gui.c
Darkvater
parents: 4218
diff changeset
    81
6505
abcb0580d976 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6414
diff changeset
    82
/* Get a list of savegames */
4223
0f9535dda7ed (svn r5767) - Cleanup: Improve upon the header file mess regarding fios. Move all relevant types from hal.h into fios.h, eliminate the unneccessary passing of a global variable, and extern variables in header files (declare in fios.c and misc_gui.c
Darkvater
parents: 4218
diff changeset
    83
FiosItem *FiosGetSavegameList(int mode);
6505
abcb0580d976 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6414
diff changeset
    84
/* Get a list of scenarios */
4223
0f9535dda7ed (svn r5767) - Cleanup: Improve upon the header file mess regarding fios. Move all relevant types from hal.h into fios.h, eliminate the unneccessary passing of a global variable, and extern variables in header files (declare in fios.c and misc_gui.c
Darkvater
parents: 4218
diff changeset
    85
FiosItem *FiosGetScenarioList(int mode);
6505
abcb0580d976 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6414
diff changeset
    86
/* Get a list of Heightmaps */
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4223
diff changeset
    87
FiosItem *FiosGetHeightmapList(int mode);
6505
abcb0580d976 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6414
diff changeset
    88
/* Free the list of savegames */
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6505
diff changeset
    89
void FiosFreeSavegameList();
6505
abcb0580d976 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6414
diff changeset
    90
/* Browse to. Returns a filename w/path if we reached a file. */
4223
0f9535dda7ed (svn r5767) - Cleanup: Improve upon the header file mess regarding fios. Move all relevant types from hal.h into fios.h, eliminate the unneccessary passing of a global variable, and extern variables in header files (declare in fios.c and misc_gui.c
Darkvater
parents: 4218
diff changeset
    91
char *FiosBrowseTo(const FiosItem *item);
6505
abcb0580d976 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6414
diff changeset
    92
/* Return path, free space and stringID */
4223
0f9535dda7ed (svn r5767) - Cleanup: Improve upon the header file mess regarding fios. Move all relevant types from hal.h into fios.h, eliminate the unneccessary passing of a global variable, and extern variables in header files (declare in fios.c and misc_gui.c
Darkvater
parents: 4218
diff changeset
    93
StringID FiosGetDescText(const char **path, uint32 *total_free);
6505
abcb0580d976 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6414
diff changeset
    94
/* Delete a name */
4223
0f9535dda7ed (svn r5767) - Cleanup: Improve upon the header file mess regarding fios. Move all relevant types from hal.h into fios.h, eliminate the unneccessary passing of a global variable, and extern variables in header files (declare in fios.c and misc_gui.c
Darkvater
parents: 4218
diff changeset
    95
bool FiosDelete(const char *name);
6505
abcb0580d976 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6414
diff changeset
    96
/* Make a filename from a name */
4223
0f9535dda7ed (svn r5767) - Cleanup: Improve upon the header file mess regarding fios. Move all relevant types from hal.h into fios.h, eliminate the unneccessary passing of a global variable, and extern variables in header files (declare in fios.c and misc_gui.c
Darkvater
parents: 4218
diff changeset
    97
void FiosMakeSavegameName(char *buf, const char *name, size_t size);
6505
abcb0580d976 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6414
diff changeset
    98
/* Allocate a new FiosItem */
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6505
diff changeset
    99
FiosItem *FiosAlloc();
4223
0f9535dda7ed (svn r5767) - Cleanup: Improve upon the header file mess regarding fios. Move all relevant types from hal.h into fios.h, eliminate the unneccessary passing of a global variable, and extern variables in header files (declare in fios.c and misc_gui.c
Darkvater
parents: 4218
diff changeset
   100
0f9535dda7ed (svn r5767) - Cleanup: Improve upon the header file mess regarding fios. Move all relevant types from hal.h into fios.h, eliminate the unneccessary passing of a global variable, and extern variables in header files (declare in fios.c and misc_gui.c
Darkvater
parents: 4218
diff changeset
   101
int CDECL compare_FiosItems(const void *a, const void *b);
0f9535dda7ed (svn r5767) - Cleanup: Improve upon the header file mess regarding fios. Move all relevant types from hal.h into fios.h, eliminate the unneccessary passing of a global variable, and extern variables in header files (declare in fios.c and misc_gui.c
Darkvater
parents: 4218
diff changeset
   102
4218
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   103
/* Implementation of opendir/readdir/closedir for Windows */
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   104
#if defined(WIN32)
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   105
#include <windows.h>
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
   106
struct DIR;
4218
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   107
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
   108
struct dirent { // XXX - only d_name implemented
6577
ee768d653dd0 (svn r9055) -Codechange: Change windows unicode handling and allow a pure non-unicode build to function. Win9x binaries will be possible with mingw/nightly system.
Darkvater
parents: 6574
diff changeset
   109
	TCHAR *d_name; // name of found file
4218
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   110
	/* little hack which will point to parent DIR struct which will
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   111
	 * save us a call to GetFileAttributes if we want information
6505
abcb0580d976 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6414
diff changeset
   112
	 * about the file (for example in function fio_bla) */
4218
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   113
	DIR *dir;
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
   114
};
4218
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   115
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   116
struct DIR {
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   117
	HANDLE hFind;
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   118
	/* the dirent returned by readdir.
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   119
	 * note: having only one global instance is not possible because
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   120
	 * multiple independent opendir/readdir sequences must be supported. */
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   121
	dirent ent;
6577
ee768d653dd0 (svn r9055) -Codechange: Change windows unicode handling and allow a pure non-unicode build to function. Win9x binaries will be possible with mingw/nightly system.
Darkvater
parents: 6574
diff changeset
   122
	WIN32_FIND_DATA fd;
4218
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   123
	/* since opendir calls FindFirstFile, we need a means of telling the
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   124
	 * first call to readdir that we already have a file.
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   125
	 * that's the case iff this is true */
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   126
	bool at_first_entry;
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   127
};
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   128
6577
ee768d653dd0 (svn r9055) -Codechange: Change windows unicode handling and allow a pure non-unicode build to function. Win9x binaries will be possible with mingw/nightly system.
Darkvater
parents: 6574
diff changeset
   129
DIR *opendir(const TCHAR *path);
4218
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   130
struct dirent *readdir(DIR *d);
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   131
int closedir(DIR *d);
6414
3a4b44cf00b1 (svn r8823) -Fix (r8821): wrapping opendir to ottd-specific function failed on non-windows because this wrapper was only active for win32 (thx Rubidium)
Darkvater
parents: 6412
diff changeset
   132
#else
3a4b44cf00b1 (svn r8823) -Fix (r8821): wrapping opendir to ottd-specific function failed on non-windows because this wrapper was only active for win32 (thx Rubidium)
Darkvater
parents: 6412
diff changeset
   133
/* Use system-supplied opendir/readdir/closedir functions */
3a4b44cf00b1 (svn r8823) -Fix (r8821): wrapping opendir to ottd-specific function failed on non-windows because this wrapper was only active for win32 (thx Rubidium)
Darkvater
parents: 6412
diff changeset
   134
# include <sys/types.h>
3a4b44cf00b1 (svn r8823) -Fix (r8821): wrapping opendir to ottd-specific function failed on non-windows because this wrapper was only active for win32 (thx Rubidium)
Darkvater
parents: 6412
diff changeset
   135
# include <dirent.h>
4218
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   136
#endif /* defined(WIN32) */
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   137
6412
a77de25206bc (svn r8821) -Regression: Unable to browse directories on *nix if the filesystem is not in UTF-8 charset and special characters are used. The string passed to opendir() which is UTF-8 was not parsed back to the filesystem format. Use a wrapper called ttd_opendir() instead of redefining opendir itself.
Darkvater
parents: 5726
diff changeset
   138
/**
a77de25206bc (svn r8821) -Regression: Unable to browse directories on *nix if the filesystem is not in UTF-8 charset and special characters are used. The string passed to opendir() which is UTF-8 was not parsed back to the filesystem format. Use a wrapper called ttd_opendir() instead of redefining opendir itself.
Darkvater
parents: 5726
diff changeset
   139
 * A wrapper around opendir() which will convert the string from
a77de25206bc (svn r8821) -Regression: Unable to browse directories on *nix if the filesystem is not in UTF-8 charset and special characters are used. The string passed to opendir() which is UTF-8 was not parsed back to the filesystem format. Use a wrapper called ttd_opendir() instead of redefining opendir itself.
Darkvater
parents: 5726
diff changeset
   140
 * OPENTTD encoding to that of the filesystem. For all purposes this
a77de25206bc (svn r8821) -Regression: Unable to browse directories on *nix if the filesystem is not in UTF-8 charset and special characters are used. The string passed to opendir() which is UTF-8 was not parsed back to the filesystem format. Use a wrapper called ttd_opendir() instead of redefining opendir itself.
Darkvater
parents: 5726
diff changeset
   141
 * function behaves the same as the original opendir function
a77de25206bc (svn r8821) -Regression: Unable to browse directories on *nix if the filesystem is not in UTF-8 charset and special characters are used. The string passed to opendir() which is UTF-8 was not parsed back to the filesystem format. Use a wrapper called ttd_opendir() instead of redefining opendir itself.
Darkvater
parents: 5726
diff changeset
   142
 * @param path string to open directory of
a77de25206bc (svn r8821) -Regression: Unable to browse directories on *nix if the filesystem is not in UTF-8 charset and special characters are used. The string passed to opendir() which is UTF-8 was not parsed back to the filesystem format. Use a wrapper called ttd_opendir() instead of redefining opendir itself.
Darkvater
parents: 5726
diff changeset
   143
 * @return DIR pointer
a77de25206bc (svn r8821) -Regression: Unable to browse directories on *nix if the filesystem is not in UTF-8 charset and special characters are used. The string passed to opendir() which is UTF-8 was not parsed back to the filesystem format. Use a wrapper called ttd_opendir() instead of redefining opendir itself.
Darkvater
parents: 5726
diff changeset
   144
 */
a77de25206bc (svn r8821) -Regression: Unable to browse directories on *nix if the filesystem is not in UTF-8 charset and special characters are used. The string passed to opendir() which is UTF-8 was not parsed back to the filesystem format. Use a wrapper called ttd_opendir() instead of redefining opendir itself.
Darkvater
parents: 5726
diff changeset
   145
static inline DIR *ttd_opendir(const char *path)
a77de25206bc (svn r8821) -Regression: Unable to browse directories on *nix if the filesystem is not in UTF-8 charset and special characters are used. The string passed to opendir() which is UTF-8 was not parsed back to the filesystem format. Use a wrapper called ttd_opendir() instead of redefining opendir itself.
Darkvater
parents: 5726
diff changeset
   146
{
a77de25206bc (svn r8821) -Regression: Unable to browse directories on *nix if the filesystem is not in UTF-8 charset and special characters are used. The string passed to opendir() which is UTF-8 was not parsed back to the filesystem format. Use a wrapper called ttd_opendir() instead of redefining opendir itself.
Darkvater
parents: 5726
diff changeset
   147
	return opendir(OTTD2FS(path));
a77de25206bc (svn r8821) -Regression: Unable to browse directories on *nix if the filesystem is not in UTF-8 charset and special characters are used. The string passed to opendir() which is UTF-8 was not parsed back to the filesystem format. Use a wrapper called ttd_opendir() instead of redefining opendir itself.
Darkvater
parents: 5726
diff changeset
   148
}
a77de25206bc (svn r8821) -Regression: Unable to browse directories on *nix if the filesystem is not in UTF-8 charset and special characters are used. The string passed to opendir() which is UTF-8 was not parsed back to the filesystem format. Use a wrapper called ttd_opendir() instead of redefining opendir itself.
Darkvater
parents: 5726
diff changeset
   149
4218
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   150
#endif /* FIOS_H */