src/fios.h
author rubidium
Sat, 21 Jun 2008 13:40:17 +0000
branchnoai
changeset 11044 097ea3e7ec56
parent 10829 8a0ec0f0f928
permissions -rw-r--r--
(svn r13600) [NoAI] -Sync: with trunk r13508:13599.
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
9724
b39bc69bb2f2 (svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents: 9723
diff changeset
     8
#include "strings_type.h"
11044
097ea3e7ec56 (svn r13600) [NoAI] -Sync: with trunk r13508:13599.
rubidium
parents: 10829
diff changeset
     9
#include "core/smallvec_type.hpp"
9724
b39bc69bb2f2 (svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents: 9723
diff changeset
    10
9722
ebf0ece7d8f6 (svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents: 6577
diff changeset
    11
enum {
ebf0ece7d8f6 (svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents: 6577
diff changeset
    12
	/**
ebf0ece7d8f6 (svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents: 6577
diff changeset
    13
	 * Slot used for the GRF scanning and such. This slot cannot be reused
ebf0ece7d8f6 (svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents: 6577
diff changeset
    14
	 * as it will otherwise cause issues when pressing "rescan directories".
ebf0ece7d8f6 (svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents: 6577
diff changeset
    15
	 * It can furthermore not be larger than LAST_GRF_SLOT as that complicates
ebf0ece7d8f6 (svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents: 6577
diff changeset
    16
	 * the testing for "too much NewGRFs".
ebf0ece7d8f6 (svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents: 6577
diff changeset
    17
	 */
ebf0ece7d8f6 (svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents: 6577
diff changeset
    18
	CONFIG_SLOT    =  0,
ebf0ece7d8f6 (svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents: 6577
diff changeset
    19
	/** Slot for the sound. */
ebf0ece7d8f6 (svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents: 6577
diff changeset
    20
	SOUND_SLOT     =  1,
ebf0ece7d8f6 (svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents: 6577
diff changeset
    21
	/** First slot useable for (New)GRFs used during the game. */
ebf0ece7d8f6 (svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents: 6577
diff changeset
    22
	FIRST_GRF_SLOT =  2,
ebf0ece7d8f6 (svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents: 6577
diff changeset
    23
	/** Last slot useable for (New)GRFs used during the game. */
ebf0ece7d8f6 (svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents: 6577
diff changeset
    24
	LAST_GRF_SLOT  = 63,
ebf0ece7d8f6 (svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents: 6577
diff changeset
    25
	/** Maximum number of slots. */
ebf0ece7d8f6 (svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents: 6577
diff changeset
    26
	MAX_FILE_SLOTS = 64
ebf0ece7d8f6 (svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents: 6577
diff changeset
    27
};
ebf0ece7d8f6 (svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents: 6577
diff changeset
    28
9723
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9722
diff changeset
    29
enum SaveLoadDialogMode{
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9722
diff changeset
    30
	SLD_LOAD_GAME,
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9722
diff changeset
    31
	SLD_LOAD_SCENARIO,
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9722
diff changeset
    32
	SLD_SAVE_GAME,
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9722
diff changeset
    33
	SLD_SAVE_SCENARIO,
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9722
diff changeset
    34
	SLD_LOAD_HEIGHTMAP,
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9722
diff changeset
    35
	SLD_NEW_GAME,
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9722
diff changeset
    36
};
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9722
diff changeset
    37
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9722
diff changeset
    38
/* The different types of files been handled by the system */
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9722
diff changeset
    39
enum FileType {
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9722
diff changeset
    40
	FT_NONE,      ///< nothing to do
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9722
diff changeset
    41
	FT_SAVEGAME,  ///< old or new savegame
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9722
diff changeset
    42
	FT_SCENARIO,  ///< old or new scenario
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9722
diff changeset
    43
	FT_HEIGHTMAP, ///< heightmap file
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
    44
};
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
    45
10355
ee4b5f7a5bf2 (svn r12896) [NoAI] -Sync: with trunk r12824:r12895.
rubidium
parents: 9724
diff changeset
    46
enum FiosType {
ee4b5f7a5bf2 (svn r12896) [NoAI] -Sync: with trunk r12824:r12895.
rubidium
parents: 9724
diff changeset
    47
	FIOS_TYPE_DRIVE,
ee4b5f7a5bf2 (svn r12896) [NoAI] -Sync: with trunk r12824:r12895.
rubidium
parents: 9724
diff changeset
    48
	FIOS_TYPE_PARENT,
ee4b5f7a5bf2 (svn r12896) [NoAI] -Sync: with trunk r12824:r12895.
rubidium
parents: 9724
diff changeset
    49
	FIOS_TYPE_DIR,
ee4b5f7a5bf2 (svn r12896) [NoAI] -Sync: with trunk r12824:r12895.
rubidium
parents: 9724
diff changeset
    50
	FIOS_TYPE_FILE,
ee4b5f7a5bf2 (svn r12896) [NoAI] -Sync: with trunk r12824:r12895.
rubidium
parents: 9724
diff changeset
    51
	FIOS_TYPE_OLDFILE,
ee4b5f7a5bf2 (svn r12896) [NoAI] -Sync: with trunk r12824:r12895.
rubidium
parents: 9724
diff changeset
    52
	FIOS_TYPE_SCENARIO,
ee4b5f7a5bf2 (svn r12896) [NoAI] -Sync: with trunk r12824:r12895.
rubidium
parents: 9724
diff changeset
    53
	FIOS_TYPE_OLD_SCENARIO,
ee4b5f7a5bf2 (svn r12896) [NoAI] -Sync: with trunk r12824:r12895.
rubidium
parents: 9724
diff changeset
    54
	FIOS_TYPE_DIRECT,
ee4b5f7a5bf2 (svn r12896) [NoAI] -Sync: with trunk r12824:r12895.
rubidium
parents: 9724
diff changeset
    55
	FIOS_TYPE_PNG,
ee4b5f7a5bf2 (svn r12896) [NoAI] -Sync: with trunk r12824:r12895.
rubidium
parents: 9724
diff changeset
    56
	FIOS_TYPE_BMP,
ee4b5f7a5bf2 (svn r12896) [NoAI] -Sync: with trunk r12824:r12895.
rubidium
parents: 9724
diff changeset
    57
	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
    58
};
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
    59
9723
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9722
diff changeset
    60
/* Deals with finding savegames */
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9722
diff changeset
    61
struct FiosItem {
10355
ee4b5f7a5bf2 (svn r12896) [NoAI] -Sync: with trunk r12824:r12895.
rubidium
parents: 9724
diff changeset
    62
	FiosType type;
9723
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9722
diff changeset
    63
	uint64 mtime;
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9722
diff changeset
    64
	char title[64];
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9722
diff changeset
    65
	char name[256 - 12 - 64];
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9722
diff changeset
    66
};
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9722
diff changeset
    67
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9722
diff changeset
    68
/* Deals with the type of the savegame, independent of extension */
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9722
diff changeset
    69
struct SmallFiosItem {
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9722
diff changeset
    70
	int mode;             ///< savegame/scenario type (old, new)
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9722
diff changeset
    71
	FileType filetype;    ///< what type of file are we dealing with
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9722
diff changeset
    72
	char name[MAX_PATH];  ///< name
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9722
diff changeset
    73
	char title[255];      ///< internal name of the game
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9722
diff changeset
    74
};
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9722
diff changeset
    75
10776
07203fc29812 (svn r13326) [NoAI] -Sync with trunk r13264:13325
glx
parents: 10355
diff changeset
    76
enum {
07203fc29812 (svn r13326) [NoAI] -Sync with trunk r13264:13325
glx
parents: 10355
diff changeset
    77
	SORT_ASCENDING  = 0,
07203fc29812 (svn r13326) [NoAI] -Sync with trunk r13264:13325
glx
parents: 10355
diff changeset
    78
	SORT_DESCENDING = 1,
07203fc29812 (svn r13326) [NoAI] -Sync with trunk r13264:13325
glx
parents: 10355
diff changeset
    79
	SORT_BY_DATE    = 0,
07203fc29812 (svn r13326) [NoAI] -Sync with trunk r13264:13325
glx
parents: 10355
diff changeset
    80
	SORT_BY_NAME    = 2
07203fc29812 (svn r13326) [NoAI] -Sync with trunk r13264:13325
glx
parents: 10355
diff changeset
    81
};
07203fc29812 (svn r13326) [NoAI] -Sync with trunk r13264:13325
glx
parents: 10355
diff changeset
    82
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
/* Variables to display file lists */
10829
8a0ec0f0f928 (svn r13381) [NoAI] -Sync with trunk r13325:13380
glx
parents: 10776
diff changeset
    84
extern SmallVector<FiosItem, 32> _fios_items; ///< defined in fios.cpp
9723
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9722
diff changeset
    85
extern SmallFiosItem _file_to_saveload;
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9722
diff changeset
    86
extern SaveLoadDialogMode _saveload_mode;   ///< defined in misc_gui.cpp
10776
07203fc29812 (svn r13326) [NoAI] -Sync with trunk r13264:13325
glx
parents: 10355
diff changeset
    87
extern byte _savegame_sort_order;
9723
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9722
diff changeset
    88
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9722
diff changeset
    89
/* Launch save/load dialog */
eee46cb39750 (svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents: 9722
diff changeset
    90
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
    91
6505
abcb0580d976 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6414
diff changeset
    92
/* Get a list of savegames */
10829
8a0ec0f0f928 (svn r13381) [NoAI] -Sync with trunk r13325:13380
glx
parents: 10776
diff changeset
    93
void FiosGetSavegameList(SaveLoadDialogMode mode);
6505
abcb0580d976 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6414
diff changeset
    94
/* Get a list of scenarios */
10829
8a0ec0f0f928 (svn r13381) [NoAI] -Sync with trunk r13325:13380
glx
parents: 10776
diff changeset
    95
void FiosGetScenarioList(SaveLoadDialogMode mode);
6505
abcb0580d976 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6414
diff changeset
    96
/* Get a list of Heightmaps */
10829
8a0ec0f0f928 (svn r13381) [NoAI] -Sync with trunk r13325:13380
glx
parents: 10776
diff changeset
    97
void FiosGetHeightmapList(SaveLoadDialogMode mode);
6505
abcb0580d976 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6414
diff changeset
    98
/* Free the list of savegames */
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6505
diff changeset
    99
void FiosFreeSavegameList();
6505
abcb0580d976 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 6414
diff changeset
   100
/* 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
   101
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
   102
/* 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
   103
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
   104
/* 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
   105
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
   106
/* 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
   107
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
   108
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
   109
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
   110
4218
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   111
/* 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
   112
#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
   113
#include <windows.h>
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
   114
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
   115
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
   116
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
   117
	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
   118
	/* 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
   119
	 * 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
   120
	 * 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
   121
	DIR *dir;
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
   122
};
4218
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   123
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   124
struct DIR {
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   125
	HANDLE hFind;
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   126
	/* 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
   127
	 * 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
   128
	 * 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
   129
	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
   130
	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
   131
	/* 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
   132
	 * 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
   133
	 * 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
   134
	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
   135
};
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   136
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
   137
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
   138
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
   139
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
   140
#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
   141
/* 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
   142
# 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
   143
# 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
   144
#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
   145
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
   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
 * 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
   148
 * 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
   149
 * 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
   150
 * @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
   151
 * @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
   152
 */
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
   153
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
   154
{
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
   155
	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
   156
}
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
   157
4218
384c7451e3bb (svn r5762) - Codechange: Implementation of POSIX-style opendir/readdir/closedir functions for windows using FindFirstFile/FindNextFile/FindClose.
Darkvater
parents:
diff changeset
   158
#endif /* FIOS_H */