author | translators |
Mon, 01 Dec 2008 18:28:44 +0000 | |
changeset 10396 | 7f6f37c9dc67 |
parent 10047 | a5c34dea770c |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
10039
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
3 |
/** @file fileio_func.h Functions for Standard In/Out file operations */ |
6179
d19b0137d8e4
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
5475
diff
changeset
|
4 |
|
10039
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
5 |
#ifndef FILEIO_FUNC_H |
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
6 |
#define FILEIO_FUNC_H |
0 | 7 |
|
10039
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
8 |
#include "fileio_type.h" |
6929
56470c1b8a66
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
6896
diff
changeset
|
9 |
|
9390
88d36f907e96
(svn r13301) -Fix [FS#1997]: resolve more MSVC 9 x64 warnings.
rubidium
parents:
9146
diff
changeset
|
10 |
void FioSeekTo(size_t pos, int mode); |
88d36f907e96
(svn r13301) -Fix [FS#1997]: resolve more MSVC 9 x64 warnings.
rubidium
parents:
9146
diff
changeset
|
11 |
void FioSeekToFile(uint8 slot, size_t pos); |
88d36f907e96
(svn r13301) -Fix [FS#1997]: resolve more MSVC 9 x64 warnings.
rubidium
parents:
9146
diff
changeset
|
12 |
size_t FioGetPos(); |
8374
7a1b6c89cb89
(svn r11940) -Codechange: Store short filename once per open file instead of once per sprite cache entry. Not all file types need this, but most of the time no sprite cache entry needed it either.
peter1138
parents:
8263
diff
changeset
|
13 |
const char *FioGetFilename(uint8 slot); |
6247 | 14 |
byte FioReadByte(); |
15 |
uint16 FioReadWord(); |
|
16 |
uint32 FioReadDword(); |
|
17 |
void FioCloseAll(); |
|
0 | 18 |
void FioOpenFile(int slot, const char *filename); |
9146
dbe2317185eb
(svn r13008) -Fix [FS#1997]: silence some MSVC x64 warnings
glx
parents:
8374
diff
changeset
|
19 |
void FioReadBlock(void *ptr, size_t size); |
0 | 20 |
void FioSkipBytes(int n); |
6929
56470c1b8a66
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
6896
diff
changeset
|
21 |
void FioCreateDirectory(const char *filename); |
6298
01c80746f308
(svn r9129) -Codechange: unify parts of DeterminePaths.
rubidium
parents:
6247
diff
changeset
|
22 |
|
6929
56470c1b8a66
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
6896
diff
changeset
|
23 |
/** |
56470c1b8a66
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
6896
diff
changeset
|
24 |
* The searchpaths OpenTTD could search through. |
56470c1b8a66
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
6896
diff
changeset
|
25 |
* At least one of the slots has to be filled with a path. |
56470c1b8a66
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
6896
diff
changeset
|
26 |
* NULL paths tell that there is no such path for the |
56470c1b8a66
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
6896
diff
changeset
|
27 |
* current operating system. |
56470c1b8a66
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
6896
diff
changeset
|
28 |
*/ |
56470c1b8a66
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
6896
diff
changeset
|
29 |
extern const char *_searchpaths[NUM_SEARCHPATHS]; |
56470c1b8a66
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
6896
diff
changeset
|
30 |
|
56470c1b8a66
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
6896
diff
changeset
|
31 |
/** |
56470c1b8a66
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
6896
diff
changeset
|
32 |
* Checks whether the given search path is a valid search path |
56470c1b8a66
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
6896
diff
changeset
|
33 |
* @param sp the search path to check |
56470c1b8a66
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
6896
diff
changeset
|
34 |
* @return true if the search path is valid |
56470c1b8a66
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
6896
diff
changeset
|
35 |
*/ |
56470c1b8a66
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
6896
diff
changeset
|
36 |
static inline bool IsValidSearchPath(Searchpath sp) |
56470c1b8a66
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
6896
diff
changeset
|
37 |
{ |
56470c1b8a66
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
6896
diff
changeset
|
38 |
return sp < NUM_SEARCHPATHS && _searchpaths[sp] != NULL; |
56470c1b8a66
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
6896
diff
changeset
|
39 |
} |
56470c1b8a66
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
6896
diff
changeset
|
40 |
|
56470c1b8a66
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
6896
diff
changeset
|
41 |
/** Iterator for all the search paths */ |
6944
53e2a7e57071
(svn r10198) -Fix (r10194): did not search all search paths.
rubidium
parents:
6941
diff
changeset
|
42 |
#define FOR_ALL_SEARCHPATHS(sp) for (sp = SP_FIRST_DIR; sp < NUM_SEARCHPATHS; sp++) if (IsValidSearchPath(sp)) |
6929
56470c1b8a66
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
6896
diff
changeset
|
43 |
|
7592
792daecf7c77
(svn r11119) -Codechange: analyze .tar files upon loading, remembering their files and offsets, which speeds up .tar handling with a big factor
truelight
parents:
7584
diff
changeset
|
44 |
void FioFCloseFile(FILE *f); |
7574
40e7c5575a2a
(svn r11099) -Codechange: allow on opening of a file via FioFOpenFile to request the size of the file, so we can keep that in mind
truelight
parents:
7570
diff
changeset
|
45 |
FILE *FioFOpenFile(const char *filename, const char *mode = "rb", Subdirectory subdir = DATA_DIR, size_t *filesize = NULL); |
6929
56470c1b8a66
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
6896
diff
changeset
|
46 |
bool FioCheckFileExists(const char *filename, Subdirectory subdir = DATA_DIR); |
56470c1b8a66
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
6896
diff
changeset
|
47 |
char *FioGetFullPath(char *buf, size_t buflen, Searchpath sp, Subdirectory subdir, const char *filename); |
56470c1b8a66
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
6896
diff
changeset
|
48 |
char *FioFindFullPath(char *buf, size_t buflen, Subdirectory subdir, const char *filename); |
56470c1b8a66
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
6896
diff
changeset
|
49 |
char *FioAppendDirectory(char *buf, size_t buflen, Searchpath sp, Subdirectory subdir); |
56470c1b8a66
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
6896
diff
changeset
|
50 |
char *FioGetDirectory(char *buf, size_t buflen, Subdirectory subdir); |
56470c1b8a66
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
6896
diff
changeset
|
51 |
|
56470c1b8a66
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
6896
diff
changeset
|
52 |
static inline const char *FioGetSubdirectory(Subdirectory subdir) |
56470c1b8a66
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
6896
diff
changeset
|
53 |
{ |
56470c1b8a66
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
6896
diff
changeset
|
54 |
extern const char *_subdirs[NUM_SUBDIRS]; |
56470c1b8a66
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
6896
diff
changeset
|
55 |
assert(subdir < NUM_SUBDIRS); |
56470c1b8a66
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
6896
diff
changeset
|
56 |
return _subdirs[subdir]; |
56470c1b8a66
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
6896
diff
changeset
|
57 |
} |
6298
01c80746f308
(svn r9129) -Codechange: unify parts of DeterminePaths.
rubidium
parents:
6247
diff
changeset
|
58 |
|
6875
e517a59b78e5
(svn r10116) -Fix [FS#850]: remove invalid characters (for the file system) from savegame names. Based on a patch by TheJosh.
rubidium
parents:
6317
diff
changeset
|
59 |
void SanitizeFilename(char *filename); |
6298
01c80746f308
(svn r9129) -Codechange: unify parts of DeterminePaths.
rubidium
parents:
6247
diff
changeset
|
60 |
void AppendPathSeparator(char *buf, size_t buflen); |
6317
70f4e9e52eb1
(svn r9266) -Codechange: unify the retrieval of the base paths a little more.
rubidium
parents:
6298
diff
changeset
|
61 |
void DeterminePaths(const char *exe); |
8131
160939e24ed3
(svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents:
8130
diff
changeset
|
62 |
void *ReadFileToMem(const char *filename, size_t *lenp, size_t maxsize); |
160939e24ed3
(svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents:
8130
diff
changeset
|
63 |
bool FileExists(const char *filename); |
0 | 64 |
|
6929
56470c1b8a66
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
6896
diff
changeset
|
65 |
extern char *_personal_dir; ///< custom directory for personal settings, saves, newgrf, etc. |
56470c1b8a66
(svn r10182) -Codechange: rewrite most part of the file loading/searching to be more flexible.
rubidium
parents:
6896
diff
changeset
|
66 |
|
10036
5c28389c3eeb
(svn r14196) -Codechange: make the searching for files with a specific extension extendable.
rubidium
parents:
9581
diff
changeset
|
67 |
/** Helper for scanning for files with a given name */ |
5c28389c3eeb
(svn r14196) -Codechange: make the searching for files with a specific extension extendable.
rubidium
parents:
9581
diff
changeset
|
68 |
class FileScanner |
5c28389c3eeb
(svn r14196) -Codechange: make the searching for files with a specific extension extendable.
rubidium
parents:
9581
diff
changeset
|
69 |
{ |
5c28389c3eeb
(svn r14196) -Codechange: make the searching for files with a specific extension extendable.
rubidium
parents:
9581
diff
changeset
|
70 |
public: |
10047
a5c34dea770c
(svn r14207) -Fix [FS#2262] (r14191): warning about non-virtual destructor in class with virtual functions.
rubidium
parents:
10039
diff
changeset
|
71 |
/** Destruct the proper one... */ |
a5c34dea770c
(svn r14207) -Fix [FS#2262] (r14191): warning about non-virtual destructor in class with virtual functions.
rubidium
parents:
10039
diff
changeset
|
72 |
virtual ~FileScanner() {} |
a5c34dea770c
(svn r14207) -Fix [FS#2262] (r14191): warning about non-virtual destructor in class with virtual functions.
rubidium
parents:
10039
diff
changeset
|
73 |
|
10036
5c28389c3eeb
(svn r14196) -Codechange: make the searching for files with a specific extension extendable.
rubidium
parents:
9581
diff
changeset
|
74 |
uint Scan(const char *extension, Subdirectory sd, bool tars = true); |
5c28389c3eeb
(svn r14196) -Codechange: make the searching for files with a specific extension extendable.
rubidium
parents:
9581
diff
changeset
|
75 |
|
5c28389c3eeb
(svn r14196) -Codechange: make the searching for files with a specific extension extendable.
rubidium
parents:
9581
diff
changeset
|
76 |
/** |
5c28389c3eeb
(svn r14196) -Codechange: make the searching for files with a specific extension extendable.
rubidium
parents:
9581
diff
changeset
|
77 |
* Add a file with the given filename. |
5c28389c3eeb
(svn r14196) -Codechange: make the searching for files with a specific extension extendable.
rubidium
parents:
9581
diff
changeset
|
78 |
* @param filename the full path to the file to read |
5c28389c3eeb
(svn r14196) -Codechange: make the searching for files with a specific extension extendable.
rubidium
parents:
9581
diff
changeset
|
79 |
* @param basepath_length amount of characters to chop of before to get a |
5c28389c3eeb
(svn r14196) -Codechange: make the searching for files with a specific extension extendable.
rubidium
parents:
9581
diff
changeset
|
80 |
* filename relative to the search path. |
5c28389c3eeb
(svn r14196) -Codechange: make the searching for files with a specific extension extendable.
rubidium
parents:
9581
diff
changeset
|
81 |
* @return true if the file is added. |
5c28389c3eeb
(svn r14196) -Codechange: make the searching for files with a specific extension extendable.
rubidium
parents:
9581
diff
changeset
|
82 |
*/ |
5c28389c3eeb
(svn r14196) -Codechange: make the searching for files with a specific extension extendable.
rubidium
parents:
9581
diff
changeset
|
83 |
virtual bool AddFile(const char *filename, size_t basepath_length) = 0; |
5c28389c3eeb
(svn r14196) -Codechange: make the searching for files with a specific extension extendable.
rubidium
parents:
9581
diff
changeset
|
84 |
}; |
5c28389c3eeb
(svn r14196) -Codechange: make the searching for files with a specific extension extendable.
rubidium
parents:
9581
diff
changeset
|
85 |
|
10039
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
86 |
|
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
87 |
/* Implementation of opendir/readdir/closedir for Windows */ |
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
88 |
#if defined(WIN32) |
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
89 |
#include <windows.h> |
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
90 |
struct DIR; |
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
91 |
|
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
92 |
struct dirent { // XXX - only d_name implemented |
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
93 |
TCHAR *d_name; // name of found file |
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
94 |
/* little hack which will point to parent DIR struct which will |
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
95 |
* save us a call to GetFileAttributes if we want information |
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
96 |
* about the file (for example in function fio_bla) */ |
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
97 |
DIR *dir; |
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
98 |
}; |
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
99 |
|
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
100 |
struct DIR { |
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
101 |
HANDLE hFind; |
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
102 |
/* the dirent returned by readdir. |
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
103 |
* note: having only one global instance is not possible because |
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
104 |
* multiple independent opendir/readdir sequences must be supported. */ |
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
105 |
dirent ent; |
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
106 |
WIN32_FIND_DATA fd; |
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
107 |
/* since opendir calls FindFirstFile, we need a means of telling the |
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
108 |
* first call to readdir that we already have a file. |
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
109 |
* that's the case iff this is true */ |
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
110 |
bool at_first_entry; |
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
111 |
}; |
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
112 |
|
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
113 |
DIR *opendir(const TCHAR *path); |
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
114 |
struct dirent *readdir(DIR *d); |
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
115 |
int closedir(DIR *d); |
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
116 |
#else |
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
117 |
/* Use system-supplied opendir/readdir/closedir functions */ |
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
118 |
# include <sys/types.h> |
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
119 |
# include <dirent.h> |
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
120 |
#endif /* defined(WIN32) */ |
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
121 |
|
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
122 |
/** |
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
123 |
* A wrapper around opendir() which will convert the string from |
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
124 |
* OPENTTD encoding to that of the filesystem. For all purposes this |
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
125 |
* function behaves the same as the original opendir function |
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
126 |
* @param path string to open directory of |
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
127 |
* @return DIR pointer |
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
128 |
*/ |
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
129 |
static inline DIR *ttd_opendir(const char *path) |
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
130 |
{ |
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
131 |
return opendir(OTTD2FS(path)); |
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
132 |
} |
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
133 |
|
1f236afd6cd1
(svn r14199) -Codechange: split fileio.h into fileio_type.h and fileio_func.h so not everything that includes saveload.h needs to include everything else too.
rubidium
parents:
10036
diff
changeset
|
134 |
#endif /* FILEIO_FUNC_H */ |