fios.h
author KUDr
Sat, 30 Dec 2006 18:25:01 +0000
branchcustombridgeheads
changeset 5609 ec38986d2c8e
parent 5167 2b9d61386688
child 5444 3209bb62403e
permissions -rw-r--r--
(svn r7655) [cbh] - Fix: [YAPF] another assert (on opposite cbh when it contained choice). Now it is possible to reach choice when exiting wormhole. So the wormhole cost must be taken into consideration when starting new YAPF node.
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
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
     3
#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
     4
#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
     5
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
     6
/* Deals with finding savegames */
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
     7
typedef struct {
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
     8
	byte type;
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
     9
	uint64 mtime;
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
    10
	char title[64];
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
    11
	char name[256 - 12 - 64];
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
    12
} FiosItem;
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
    13
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
    14
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
    15
	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
    16
	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
    17
	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
    18
	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
    19
	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
    20
	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
    21
	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
    22
	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
    23
	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
    24
	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
    25
	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
    26
};
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
    27
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
    28
/* Variables to display file lists */
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
    29
extern FiosItem *_fios_list; // defined in misc_gui.c
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
    30
extern int _fios_num;        // defined in fios.c, read_only version of _fios_count
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
    31
extern int _saveload_mode;   // defined in misc_gui.c
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
    32
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
    33
// Get a list of savegames
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
    34
FiosItem *FiosGetSavegameList(int mode);
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
    35
// Get a list of scenarios
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
    36
FiosItem *FiosGetScenarioList(int mode);
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4223
diff changeset
    37
// Get a list of Heightmaps
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4223
diff changeset
    38
FiosItem *FiosGetHeightmapList(int 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
    39
// Free the list of savegames
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
    40
void FiosFreeSavegameList(void);
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
    41
// Browse to. Returns a filename w/path if we reached a file.
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
    42
char *FiosBrowseTo(const FiosItem *item);
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
// Return path, free space and stringID
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
    44
StringID FiosGetDescText(const char **path, uint32 *total_free);
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
    45
// Delete a name
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
    46
bool FiosDelete(const char *name);
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
    47
// Make a filename from a name
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
    48
void FiosMakeSavegameName(char *buf, const char *name, size_t size);
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
    49
// Allocate a new FiosItem
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
    50
FiosItem *FiosAlloc(void);
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
    51
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
    52
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
    53
4218
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
    54
/* 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
    55
#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
    56
#include <windows.h>
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
    57
typedef struct DIR DIR;
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
    58
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
    59
typedef struct dirent { // XXX - only d_name implemented
5167
2b9d61386688 (svn r7274) -Codechange [utf8]: Add input/output unicode support. This actually only changes win32
Darkvater
parents: 4344
diff changeset
    60
	wchar_t *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
    61
	/* 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
    62
	 * save us a call to GetFileAttributes if we want information
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
    63
	 * about the file (for example in function fio_bla */
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
    64
	DIR *dir;
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
    65
} dirent;
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
    66
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
    67
struct DIR {
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
    68
	HANDLE hFind;
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
    69
	/* 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
    70
	 * 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
    71
	 * 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
    72
	dirent ent;
5167
2b9d61386688 (svn r7274) -Codechange [utf8]: Add input/output unicode support. This actually only changes win32
Darkvater
parents: 4344
diff changeset
    73
	WIN32_FIND_DATAW fd;
4218
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
    74
	/* 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
    75
	 * 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
    76
	 * 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
    77
	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
    78
};
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
    79
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
    80
DIR *opendir(const char *path);
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
    81
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
    82
int closedir(DIR *d);
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
    83
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
    84
#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
    85
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
    86
#endif /* FIOS_H */