src/fios.h
author belugas
Fri, 28 Dec 2007 03:14:55 +0000
changeset 8151 4cefeef74c28
parent 8149 1b1390cb0844
child 8152 ab21de45f8ab
permissions -rw-r--r--
(svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
4218
4033c207d304 (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
     1
/* $Id$ */
4033c207d304 (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
     2
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6088
diff changeset
     3
/** @file fios.h Declarations for savegames operations */
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6088
diff changeset
     4
4218
4033c207d304 (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
4033c207d304 (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
4033c207d304 (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
     7
7805
7ab20f94cc80 (svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium
parents: 6251
diff changeset
     8
enum {
7ab20f94cc80 (svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium
parents: 6251
diff changeset
     9
	/**
7ab20f94cc80 (svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium
parents: 6251
diff changeset
    10
	 * Slot used for the GRF scanning and such. This slot cannot be reused
7ab20f94cc80 (svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium
parents: 6251
diff changeset
    11
	 * as it will otherwise cause issues when pressing "rescan directories".
7ab20f94cc80 (svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium
parents: 6251
diff changeset
    12
	 * It can furthermore not be larger than LAST_GRF_SLOT as that complicates
7ab20f94cc80 (svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium
parents: 6251
diff changeset
    13
	 * the testing for "too much NewGRFs".
7ab20f94cc80 (svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium
parents: 6251
diff changeset
    14
	 */
7ab20f94cc80 (svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium
parents: 6251
diff changeset
    15
	CONFIG_SLOT    =  0,
7ab20f94cc80 (svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium
parents: 6251
diff changeset
    16
	/** Slot for the sound. */
7ab20f94cc80 (svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium
parents: 6251
diff changeset
    17
	SOUND_SLOT     =  1,
7ab20f94cc80 (svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium
parents: 6251
diff changeset
    18
	/** First slot useable for (New)GRFs used during the game. */
7ab20f94cc80 (svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium
parents: 6251
diff changeset
    19
	FIRST_GRF_SLOT =  2,
7ab20f94cc80 (svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium
parents: 6251
diff changeset
    20
	/** Last slot useable for (New)GRFs used during the game. */
7ab20f94cc80 (svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium
parents: 6251
diff changeset
    21
	LAST_GRF_SLOT  = 63,
7ab20f94cc80 (svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium
parents: 6251
diff changeset
    22
	/** Maximum number of slots. */
7ab20f94cc80 (svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium
parents: 6251
diff changeset
    23
	MAX_FILE_SLOTS = 64
7ab20f94cc80 (svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium
parents: 6251
diff changeset
    24
};
7ab20f94cc80 (svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium
parents: 6251
diff changeset
    25
8149
1b1390cb0844 (svn r11711) -Codechange: Name the Save Load Dialog Mode enum
belugas
parents: 7805
diff changeset
    26
enum SaveLoadDialogMode{
1b1390cb0844 (svn r11711) -Codechange: Name the Save Load Dialog Mode enum
belugas
parents: 7805
diff changeset
    27
	SLD_LOAD_GAME,
1b1390cb0844 (svn r11711) -Codechange: Name the Save Load Dialog Mode enum
belugas
parents: 7805
diff changeset
    28
	SLD_LOAD_SCENARIO,
1b1390cb0844 (svn r11711) -Codechange: Name the Save Load Dialog Mode enum
belugas
parents: 7805
diff changeset
    29
	SLD_SAVE_GAME,
1b1390cb0844 (svn r11711) -Codechange: Name the Save Load Dialog Mode enum
belugas
parents: 7805
diff changeset
    30
	SLD_SAVE_SCENARIO,
1b1390cb0844 (svn r11711) -Codechange: Name the Save Load Dialog Mode enum
belugas
parents: 7805
diff changeset
    31
	SLD_LOAD_HEIGHTMAP,
1b1390cb0844 (svn r11711) -Codechange: Name the Save Load Dialog Mode enum
belugas
parents: 7805
diff changeset
    32
	SLD_NEW_GAME,
1b1390cb0844 (svn r11711) -Codechange: Name the Save Load Dialog Mode enum
belugas
parents: 7805
diff changeset
    33
};
1b1390cb0844 (svn r11711) -Codechange: Name the Save Load Dialog Mode enum
belugas
parents: 7805
diff changeset
    34
4223
d4c9ef555f43 (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
    35
enum {
4344
7e123fec5b0b (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
    36
	FIOS_TYPE_DRIVE        =   0,
7e123fec5b0b (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
    37
	FIOS_TYPE_PARENT       =   1,
7e123fec5b0b (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
    38
	FIOS_TYPE_DIR          =   2,
7e123fec5b0b (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
    39
	FIOS_TYPE_FILE         =   3,
7e123fec5b0b (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
    40
	FIOS_TYPE_OLDFILE      =   4,
7e123fec5b0b (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
    41
	FIOS_TYPE_SCENARIO     =   5,
7e123fec5b0b (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
    42
	FIOS_TYPE_OLD_SCENARIO =   6,
7e123fec5b0b (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
    43
	FIOS_TYPE_DIRECT       =   7,
7e123fec5b0b (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_PNG          =   8,
7e123fec5b0b (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_BMP          =   9,
7e123fec5b0b (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_INVALID      = 255,
4223
d4c9ef555f43 (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
    47
};
d4c9ef555f43 (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
    48
8151
4cefeef74c28 (svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas
parents: 8149
diff changeset
    49
/* Deals with finding savegames */
4cefeef74c28 (svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas
parents: 8149
diff changeset
    50
struct FiosItem {
4cefeef74c28 (svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas
parents: 8149
diff changeset
    51
	byte type;
4cefeef74c28 (svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas
parents: 8149
diff changeset
    52
	uint64 mtime;
4cefeef74c28 (svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas
parents: 8149
diff changeset
    53
	char title[64];
4cefeef74c28 (svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas
parents: 8149
diff changeset
    54
	char name[256 - 12 - 64];
4cefeef74c28 (svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas
parents: 8149
diff changeset
    55
};
4cefeef74c28 (svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas
parents: 8149
diff changeset
    56
4cefeef74c28 (svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas
parents: 8149
diff changeset
    57
/* Deals with the type of the savegame, independent of extension */
4cefeef74c28 (svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas
parents: 8149
diff changeset
    58
struct SmallFiosItem {
4cefeef74c28 (svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas
parents: 8149
diff changeset
    59
	int mode;             ///< savegame/scenario type (old, new)
4cefeef74c28 (svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas
parents: 8149
diff changeset
    60
	char name[MAX_PATH];  ///< name
4cefeef74c28 (svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas
parents: 8149
diff changeset
    61
	char title[255];      ///< internal name of the game
4cefeef74c28 (svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas
parents: 8149
diff changeset
    62
};
4cefeef74c28 (svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas
parents: 8149
diff changeset
    63
4223
d4c9ef555f43 (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
    64
/* Variables to display file lists */
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6088
diff changeset
    65
extern FiosItem *_fios_list; ///< defined in misc_gui.cpp
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6088
diff changeset
    66
extern int _fios_num;        ///< defined in fios.cpp, read_only version of _fios_count
8151
4cefeef74c28 (svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas
parents: 8149
diff changeset
    67
extern SmallFiosItem _file_to_saveload;
8149
1b1390cb0844 (svn r11711) -Codechange: Name the Save Load Dialog Mode enum
belugas
parents: 7805
diff changeset
    68
extern SaveLoadDialogMode _saveload_mode;   ///< defined in misc_gui.cpp
1b1390cb0844 (svn r11711) -Codechange: Name the Save Load Dialog Mode enum
belugas
parents: 7805
diff changeset
    69
1b1390cb0844 (svn r11711) -Codechange: Name the Save Load Dialog Mode enum
belugas
parents: 7805
diff changeset
    70
/* Launch save/load dialog */
1b1390cb0844 (svn r11711) -Codechange: Name the Save Load Dialog Mode enum
belugas
parents: 7805
diff changeset
    71
void ShowSaveLoadDialog(SaveLoadDialogMode mode);
4223
d4c9ef555f43 (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
    72
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6088
diff changeset
    73
/* Get a list of savegames */
4223
d4c9ef555f43 (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
    74
FiosItem *FiosGetSavegameList(int mode);
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6088
diff changeset
    75
/* Get a list of scenarios */
4223
d4c9ef555f43 (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
    76
FiosItem *FiosGetScenarioList(int mode);
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6088
diff changeset
    77
/* Get a list of Heightmaps */
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4223
diff changeset
    78
FiosItem *FiosGetHeightmapList(int mode);
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6088
diff changeset
    79
/* Free the list of savegames */
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6179
diff changeset
    80
void FiosFreeSavegameList();
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6088
diff changeset
    81
/* Browse to. Returns a filename w/path if we reached a file. */
4223
d4c9ef555f43 (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
    82
char *FiosBrowseTo(const FiosItem *item);
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6088
diff changeset
    83
/* Return path, free space and stringID */
4223
d4c9ef555f43 (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
    84
StringID FiosGetDescText(const char **path, uint32 *total_free);
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6088
diff changeset
    85
/* Delete a name */
4223
d4c9ef555f43 (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
    86
bool FiosDelete(const char *name);
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6088
diff changeset
    87
/* Make a filename from a name */
4223
d4c9ef555f43 (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
    88
void FiosMakeSavegameName(char *buf, const char *name, size_t size);
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6088
diff changeset
    89
/* Allocate a new FiosItem */
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6179
diff changeset
    90
FiosItem *FiosAlloc();
4223
d4c9ef555f43 (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
d4c9ef555f43 (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
    92
int CDECL compare_FiosItems(const void *a, const void *b);
d4c9ef555f43 (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
4218
4033c207d304 (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
    94
/* Implementation of opendir/readdir/closedir for Windows */
4033c207d304 (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
    95
#if defined(WIN32)
4033c207d304 (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
    96
#include <windows.h>
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
    97
struct DIR;
4218
4033c207d304 (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
    98
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
    99
struct dirent { // XXX - only d_name implemented
6251
2ad87f850eb9 (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: 6248
diff changeset
   100
	TCHAR *d_name; // name of found file
4218
4033c207d304 (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   101
	/* little hack which will point to parent DIR struct which will
4033c207d304 (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   102
	 * save us a call to GetFileAttributes if we want information
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6088
diff changeset
   103
	 * about the file (for example in function fio_bla) */
4218
4033c207d304 (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   104
	DIR *dir;
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
   105
};
4218
4033c207d304 (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   106
4033c207d304 (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   107
struct DIR {
4033c207d304 (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   108
	HANDLE hFind;
4033c207d304 (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   109
	/* the dirent returned by readdir.
4033c207d304 (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   110
	 * note: having only one global instance is not possible because
4033c207d304 (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   111
	 * multiple independent opendir/readdir sequences must be supported. */
4033c207d304 (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   112
	dirent ent;
6251
2ad87f850eb9 (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: 6248
diff changeset
   113
	WIN32_FIND_DATA fd;
4218
4033c207d304 (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   114
	/* since opendir calls FindFirstFile, we need a means of telling the
4033c207d304 (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   115
	 * first call to readdir that we already have a file.
4033c207d304 (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   116
	 * that's the case iff this is true */
4033c207d304 (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   117
	bool at_first_entry;
4033c207d304 (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   118
};
4033c207d304 (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   119
6251
2ad87f850eb9 (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: 6248
diff changeset
   120
DIR *opendir(const TCHAR *path);
4218
4033c207d304 (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   121
struct dirent *readdir(DIR *d);
4033c207d304 (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   122
int closedir(DIR *d);
6088
f1149b4ff932 (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: 6086
diff changeset
   123
#else
f1149b4ff932 (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: 6086
diff changeset
   124
/* Use system-supplied opendir/readdir/closedir functions */
f1149b4ff932 (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: 6086
diff changeset
   125
# include <sys/types.h>
f1149b4ff932 (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: 6086
diff changeset
   126
# include <dirent.h>
4218
4033c207d304 (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   127
#endif /* defined(WIN32) */
4033c207d304 (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   128
6086
37ea367a54e6 (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: 5475
diff changeset
   129
/**
37ea367a54e6 (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: 5475
diff changeset
   130
 * A wrapper around opendir() which will convert the string from
37ea367a54e6 (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: 5475
diff changeset
   131
 * OPENTTD encoding to that of the filesystem. For all purposes this
37ea367a54e6 (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: 5475
diff changeset
   132
 * function behaves the same as the original opendir function
37ea367a54e6 (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: 5475
diff changeset
   133
 * @param path string to open directory of
37ea367a54e6 (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: 5475
diff changeset
   134
 * @return DIR pointer
37ea367a54e6 (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: 5475
diff changeset
   135
 */
37ea367a54e6 (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: 5475
diff changeset
   136
static inline DIR *ttd_opendir(const char *path)
37ea367a54e6 (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: 5475
diff changeset
   137
{
37ea367a54e6 (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: 5475
diff changeset
   138
	return opendir(OTTD2FS(path));
37ea367a54e6 (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: 5475
diff changeset
   139
}
37ea367a54e6 (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: 5475
diff changeset
   140
4218
4033c207d304 (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   141
#endif /* FIOS_H */