Mercurial > hg > openttd
annotate src/fios.h @ 9031:9c6b04429f26 draft
(svn r12848) -Cleanup/Codechange: Use correct variable types, don't prefix with _ for non-globals, and use implicit enum numbering.
author | peter1138 <peter1138@openttd.org> |
---|---|
date | Wed, 23 Apr 2008 12:03:47 +0000 |
parents | 2495310e220f |
children | bfbde09b4346 |
rev | line source |
---|---|
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
1 /* $Id$ */ |
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
2 |
6179
e3e61b92574b
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas <belugas@openttd.org>
parents:
6088
diff
changeset
|
3 /** @file fios.h Declarations for savegames operations */ |
e3e61b92574b
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas <belugas@openttd.org>
parents:
6088
diff
changeset
|
4 |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
5 #ifndef FIOS_H |
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
6 #define FIOS_H |
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
7 |
8264
2495310e220f
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents:
8152
diff
changeset
|
8 #include "strings_type.h" |
2495310e220f
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents:
8152
diff
changeset
|
9 |
7805
9a2371156469
(svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium <rubidium@openttd.org>
parents:
6251
diff
changeset
|
10 enum { |
9a2371156469
(svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium <rubidium@openttd.org>
parents:
6251
diff
changeset
|
11 /** |
9a2371156469
(svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium <rubidium@openttd.org>
parents:
6251
diff
changeset
|
12 * Slot used for the GRF scanning and such. This slot cannot be reused |
9a2371156469
(svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium <rubidium@openttd.org>
parents:
6251
diff
changeset
|
13 * as it will otherwise cause issues when pressing "rescan directories". |
9a2371156469
(svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium <rubidium@openttd.org>
parents:
6251
diff
changeset
|
14 * It can furthermore not be larger than LAST_GRF_SLOT as that complicates |
9a2371156469
(svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium <rubidium@openttd.org>
parents:
6251
diff
changeset
|
15 * the testing for "too much NewGRFs". |
9a2371156469
(svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium <rubidium@openttd.org>
parents:
6251
diff
changeset
|
16 */ |
9a2371156469
(svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium <rubidium@openttd.org>
parents:
6251
diff
changeset
|
17 CONFIG_SLOT = 0, |
9a2371156469
(svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium <rubidium@openttd.org>
parents:
6251
diff
changeset
|
18 /** Slot for the sound. */ |
9a2371156469
(svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium <rubidium@openttd.org>
parents:
6251
diff
changeset
|
19 SOUND_SLOT = 1, |
9a2371156469
(svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium <rubidium@openttd.org>
parents:
6251
diff
changeset
|
20 /** First slot useable for (New)GRFs used during the game. */ |
9a2371156469
(svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium <rubidium@openttd.org>
parents:
6251
diff
changeset
|
21 FIRST_GRF_SLOT = 2, |
9a2371156469
(svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium <rubidium@openttd.org>
parents:
6251
diff
changeset
|
22 /** Last slot useable for (New)GRFs used during the game. */ |
9a2371156469
(svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium <rubidium@openttd.org>
parents:
6251
diff
changeset
|
23 LAST_GRF_SLOT = 63, |
9a2371156469
(svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium <rubidium@openttd.org>
parents:
6251
diff
changeset
|
24 /** Maximum number of slots. */ |
9a2371156469
(svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium <rubidium@openttd.org>
parents:
6251
diff
changeset
|
25 MAX_FILE_SLOTS = 64 |
9a2371156469
(svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium <rubidium@openttd.org>
parents:
6251
diff
changeset
|
26 }; |
9a2371156469
(svn r11355) -Fix [FS#1377]: loading too many GRFs was not handled gracefully causing crashes and such.
rubidium <rubidium@openttd.org>
parents:
6251
diff
changeset
|
27 |
8149
ad7ddb6150dc
(svn r11711) -Codechange: Name the Save Load Dialog Mode enum
belugas <belugas@openttd.org>
parents:
7805
diff
changeset
|
28 enum SaveLoadDialogMode{ |
ad7ddb6150dc
(svn r11711) -Codechange: Name the Save Load Dialog Mode enum
belugas <belugas@openttd.org>
parents:
7805
diff
changeset
|
29 SLD_LOAD_GAME, |
ad7ddb6150dc
(svn r11711) -Codechange: Name the Save Load Dialog Mode enum
belugas <belugas@openttd.org>
parents:
7805
diff
changeset
|
30 SLD_LOAD_SCENARIO, |
ad7ddb6150dc
(svn r11711) -Codechange: Name the Save Load Dialog Mode enum
belugas <belugas@openttd.org>
parents:
7805
diff
changeset
|
31 SLD_SAVE_GAME, |
ad7ddb6150dc
(svn r11711) -Codechange: Name the Save Load Dialog Mode enum
belugas <belugas@openttd.org>
parents:
7805
diff
changeset
|
32 SLD_SAVE_SCENARIO, |
ad7ddb6150dc
(svn r11711) -Codechange: Name the Save Load Dialog Mode enum
belugas <belugas@openttd.org>
parents:
7805
diff
changeset
|
33 SLD_LOAD_HEIGHTMAP, |
ad7ddb6150dc
(svn r11711) -Codechange: Name the Save Load Dialog Mode enum
belugas <belugas@openttd.org>
parents:
7805
diff
changeset
|
34 SLD_NEW_GAME, |
ad7ddb6150dc
(svn r11711) -Codechange: Name the Save Load Dialog Mode enum
belugas <belugas@openttd.org>
parents:
7805
diff
changeset
|
35 }; |
ad7ddb6150dc
(svn r11711) -Codechange: Name the Save Load Dialog Mode enum
belugas <belugas@openttd.org>
parents:
7805
diff
changeset
|
36 |
8152
32bfb56e7e0e
(svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas <belugas@openttd.org>
parents:
8151
diff
changeset
|
37 /* The different types of files been handled by the system */ |
32bfb56e7e0e
(svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas <belugas@openttd.org>
parents:
8151
diff
changeset
|
38 enum FileType { |
32bfb56e7e0e
(svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas <belugas@openttd.org>
parents:
8151
diff
changeset
|
39 FT_NONE, ///< nothing to do |
32bfb56e7e0e
(svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas <belugas@openttd.org>
parents:
8151
diff
changeset
|
40 FT_SAVEGAME, ///< old or new savegame |
32bfb56e7e0e
(svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas <belugas@openttd.org>
parents:
8151
diff
changeset
|
41 FT_SCENARIO, ///< old or new scenario |
32bfb56e7e0e
(svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas <belugas@openttd.org>
parents:
8151
diff
changeset
|
42 FT_HEIGHTMAP, ///< heightmap file |
32bfb56e7e0e
(svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas <belugas@openttd.org>
parents:
8151
diff
changeset
|
43 }; |
32bfb56e7e0e
(svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas <belugas@openttd.org>
parents:
8151
diff
changeset
|
44 |
9031
9c6b04429f26
(svn r12848) -Cleanup/Codechange: Use correct variable types, don't prefix with _ for non-globals, and use implicit enum numbering.
peter1138 <peter1138@openttd.org>
parents:
8264
diff
changeset
|
45 enum FiosType { |
9c6b04429f26
(svn r12848) -Cleanup/Codechange: Use correct variable types, don't prefix with _ for non-globals, and use implicit enum numbering.
peter1138 <peter1138@openttd.org>
parents:
8264
diff
changeset
|
46 FIOS_TYPE_DRIVE, |
9c6b04429f26
(svn r12848) -Cleanup/Codechange: Use correct variable types, don't prefix with _ for non-globals, and use implicit enum numbering.
peter1138 <peter1138@openttd.org>
parents:
8264
diff
changeset
|
47 FIOS_TYPE_PARENT, |
9c6b04429f26
(svn r12848) -Cleanup/Codechange: Use correct variable types, don't prefix with _ for non-globals, and use implicit enum numbering.
peter1138 <peter1138@openttd.org>
parents:
8264
diff
changeset
|
48 FIOS_TYPE_DIR, |
9c6b04429f26
(svn r12848) -Cleanup/Codechange: Use correct variable types, don't prefix with _ for non-globals, and use implicit enum numbering.
peter1138 <peter1138@openttd.org>
parents:
8264
diff
changeset
|
49 FIOS_TYPE_FILE, |
9c6b04429f26
(svn r12848) -Cleanup/Codechange: Use correct variable types, don't prefix with _ for non-globals, and use implicit enum numbering.
peter1138 <peter1138@openttd.org>
parents:
8264
diff
changeset
|
50 FIOS_TYPE_OLDFILE, |
9c6b04429f26
(svn r12848) -Cleanup/Codechange: Use correct variable types, don't prefix with _ for non-globals, and use implicit enum numbering.
peter1138 <peter1138@openttd.org>
parents:
8264
diff
changeset
|
51 FIOS_TYPE_SCENARIO, |
9c6b04429f26
(svn r12848) -Cleanup/Codechange: Use correct variable types, don't prefix with _ for non-globals, and use implicit enum numbering.
peter1138 <peter1138@openttd.org>
parents:
8264
diff
changeset
|
52 FIOS_TYPE_OLD_SCENARIO, |
9c6b04429f26
(svn r12848) -Cleanup/Codechange: Use correct variable types, don't prefix with _ for non-globals, and use implicit enum numbering.
peter1138 <peter1138@openttd.org>
parents:
8264
diff
changeset
|
53 FIOS_TYPE_DIRECT, |
9c6b04429f26
(svn r12848) -Cleanup/Codechange: Use correct variable types, don't prefix with _ for non-globals, and use implicit enum numbering.
peter1138 <peter1138@openttd.org>
parents:
8264
diff
changeset
|
54 FIOS_TYPE_PNG, |
9c6b04429f26
(svn r12848) -Cleanup/Codechange: Use correct variable types, don't prefix with _ for non-globals, and use implicit enum numbering.
peter1138 <peter1138@openttd.org>
parents:
8264
diff
changeset
|
55 FIOS_TYPE_BMP, |
9c6b04429f26
(svn r12848) -Cleanup/Codechange: Use correct variable types, don't prefix with _ for non-globals, and use implicit enum numbering.
peter1138 <peter1138@openttd.org>
parents:
8264
diff
changeset
|
56 FIOS_TYPE_INVALID = 255, |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
57 }; |
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
58 |
8151
bee108a98a39
(svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas <belugas@openttd.org>
parents:
8149
diff
changeset
|
59 /* Deals with finding savegames */ |
bee108a98a39
(svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas <belugas@openttd.org>
parents:
8149
diff
changeset
|
60 struct FiosItem { |
9031
9c6b04429f26
(svn r12848) -Cleanup/Codechange: Use correct variable types, don't prefix with _ for non-globals, and use implicit enum numbering.
peter1138 <peter1138@openttd.org>
parents:
8264
diff
changeset
|
61 FiosType type; |
8151
bee108a98a39
(svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas <belugas@openttd.org>
parents:
8149
diff
changeset
|
62 uint64 mtime; |
bee108a98a39
(svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas <belugas@openttd.org>
parents:
8149
diff
changeset
|
63 char title[64]; |
bee108a98a39
(svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas <belugas@openttd.org>
parents:
8149
diff
changeset
|
64 char name[256 - 12 - 64]; |
bee108a98a39
(svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas <belugas@openttd.org>
parents:
8149
diff
changeset
|
65 }; |
bee108a98a39
(svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas <belugas@openttd.org>
parents:
8149
diff
changeset
|
66 |
bee108a98a39
(svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas <belugas@openttd.org>
parents:
8149
diff
changeset
|
67 /* Deals with the type of the savegame, independent of extension */ |
bee108a98a39
(svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas <belugas@openttd.org>
parents:
8149
diff
changeset
|
68 struct SmallFiosItem { |
bee108a98a39
(svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas <belugas@openttd.org>
parents:
8149
diff
changeset
|
69 int mode; ///< savegame/scenario type (old, new) |
8152
32bfb56e7e0e
(svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
belugas <belugas@openttd.org>
parents:
8151
diff
changeset
|
70 FileType filetype; ///< what type of file are we dealing with |
8151
bee108a98a39
(svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas <belugas@openttd.org>
parents:
8149
diff
changeset
|
71 char name[MAX_PATH]; ///< name |
bee108a98a39
(svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas <belugas@openttd.org>
parents:
8149
diff
changeset
|
72 char title[255]; ///< internal name of the game |
bee108a98a39
(svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas <belugas@openttd.org>
parents:
8149
diff
changeset
|
73 }; |
bee108a98a39
(svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas <belugas@openttd.org>
parents:
8149
diff
changeset
|
74 |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
75 /* Variables to display file lists */ |
6179
e3e61b92574b
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas <belugas@openttd.org>
parents:
6088
diff
changeset
|
76 extern FiosItem *_fios_list; ///< defined in misc_gui.cpp |
e3e61b92574b
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas <belugas@openttd.org>
parents:
6088
diff
changeset
|
77 extern int _fios_num; ///< defined in fios.cpp, read_only version of _fios_count |
8151
bee108a98a39
(svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas <belugas@openttd.org>
parents:
8149
diff
changeset
|
78 extern SmallFiosItem _file_to_saveload; |
8149
ad7ddb6150dc
(svn r11711) -Codechange: Name the Save Load Dialog Mode enum
belugas <belugas@openttd.org>
parents:
7805
diff
changeset
|
79 extern SaveLoadDialogMode _saveload_mode; ///< defined in misc_gui.cpp |
ad7ddb6150dc
(svn r11711) -Codechange: Name the Save Load Dialog Mode enum
belugas <belugas@openttd.org>
parents:
7805
diff
changeset
|
80 |
ad7ddb6150dc
(svn r11711) -Codechange: Name the Save Load Dialog Mode enum
belugas <belugas@openttd.org>
parents:
7805
diff
changeset
|
81 /* Launch save/load dialog */ |
ad7ddb6150dc
(svn r11711) -Codechange: Name the Save Load Dialog Mode enum
belugas <belugas@openttd.org>
parents:
7805
diff
changeset
|
82 void ShowSaveLoadDialog(SaveLoadDialogMode mode); |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
83 |
6179
e3e61b92574b
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas <belugas@openttd.org>
parents:
6088
diff
changeset
|
84 /* Get a list of savegames */ |
9031
9c6b04429f26
(svn r12848) -Cleanup/Codechange: Use correct variable types, don't prefix with _ for non-globals, and use implicit enum numbering.
peter1138 <peter1138@openttd.org>
parents:
8264
diff
changeset
|
85 FiosItem *FiosGetSavegameList(SaveLoadDialogMode mode); |
6179
e3e61b92574b
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas <belugas@openttd.org>
parents:
6088
diff
changeset
|
86 /* Get a list of scenarios */ |
9031
9c6b04429f26
(svn r12848) -Cleanup/Codechange: Use correct variable types, don't prefix with _ for non-globals, and use implicit enum numbering.
peter1138 <peter1138@openttd.org>
parents:
8264
diff
changeset
|
87 FiosItem *FiosGetScenarioList(SaveLoadDialogMode mode); |
6179
e3e61b92574b
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas <belugas@openttd.org>
parents:
6088
diff
changeset
|
88 /* Get a list of Heightmaps */ |
9031
9c6b04429f26
(svn r12848) -Cleanup/Codechange: Use correct variable types, don't prefix with _ for non-globals, and use implicit enum numbering.
peter1138 <peter1138@openttd.org>
parents:
8264
diff
changeset
|
89 FiosItem *FiosGetHeightmapList(SaveLoadDialogMode mode); |
6179
e3e61b92574b
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas <belugas@openttd.org>
parents:
6088
diff
changeset
|
90 /* Free the list of savegames */ |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6179
diff
changeset
|
91 void FiosFreeSavegameList(); |
6179
e3e61b92574b
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas <belugas@openttd.org>
parents:
6088
diff
changeset
|
92 /* Browse to. Returns a filename w/path if we reached a file. */ |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
93 char *FiosBrowseTo(const FiosItem *item); |
6179
e3e61b92574b
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas <belugas@openttd.org>
parents:
6088
diff
changeset
|
94 /* Return path, free space and stringID */ |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
95 StringID FiosGetDescText(const char **path, uint32 *total_free); |
6179
e3e61b92574b
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas <belugas@openttd.org>
parents:
6088
diff
changeset
|
96 /* Delete a name */ |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
97 bool FiosDelete(const char *name); |
6179
e3e61b92574b
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas <belugas@openttd.org>
parents:
6088
diff
changeset
|
98 /* Make a filename from a name */ |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
99 void FiosMakeSavegameName(char *buf, const char *name, size_t size); |
6179
e3e61b92574b
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas <belugas@openttd.org>
parents:
6088
diff
changeset
|
100 /* Allocate a new FiosItem */ |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6179
diff
changeset
|
101 FiosItem *FiosAlloc(); |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
102 |
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
103 int CDECL compare_FiosItems(const void *a, const void *b); |
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
104 |
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
105 /* Implementation of opendir/readdir/closedir for Windows */ |
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
106 #if defined(WIN32) |
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
107 #include <windows.h> |
6248
0789677a15a0
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents:
6247
diff
changeset
|
108 struct DIR; |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
109 |
6248
0789677a15a0
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents:
6247
diff
changeset
|
110 struct dirent { // XXX - only d_name implemented |
6251
9953c75f16bc
(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 <Darkvater@openttd.org>
parents:
6248
diff
changeset
|
111 TCHAR *d_name; // name of found file |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
112 /* little hack which will point to parent DIR struct which will |
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
113 * save us a call to GetFileAttributes if we want information |
6179
e3e61b92574b
(svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas <belugas@openttd.org>
parents:
6088
diff
changeset
|
114 * about the file (for example in function fio_bla) */ |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
115 DIR *dir; |
6248
0789677a15a0
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents:
6247
diff
changeset
|
116 }; |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
117 |
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
118 struct DIR { |
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
119 HANDLE hFind; |
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
120 /* the dirent returned by readdir. |
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
121 * note: having only one global instance is not possible because |
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
122 * multiple independent opendir/readdir sequences must be supported. */ |
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
123 dirent ent; |
6251
9953c75f16bc
(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 <Darkvater@openttd.org>
parents:
6248
diff
changeset
|
124 WIN32_FIND_DATA fd; |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
125 /* since opendir calls FindFirstFile, we need a means of telling the |
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
126 * first call to readdir that we already have a file. |
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
127 * that's the case iff this is true */ |
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
128 bool at_first_entry; |
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
129 }; |
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
130 |
6251
9953c75f16bc
(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 <Darkvater@openttd.org>
parents:
6248
diff
changeset
|
131 DIR *opendir(const TCHAR *path); |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
132 struct dirent *readdir(DIR *d); |
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
133 int closedir(DIR *d); |
6088
636539830f0e
(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 <Darkvater@openttd.org>
parents:
6086
diff
changeset
|
134 #else |
636539830f0e
(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 <Darkvater@openttd.org>
parents:
6086
diff
changeset
|
135 /* Use system-supplied opendir/readdir/closedir functions */ |
636539830f0e
(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 <Darkvater@openttd.org>
parents:
6086
diff
changeset
|
136 # include <sys/types.h> |
636539830f0e
(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 <Darkvater@openttd.org>
parents:
6086
diff
changeset
|
137 # include <dirent.h> |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
138 #endif /* defined(WIN32) */ |
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
139 |
6086
d242fc975d65
(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 <Darkvater@openttd.org>
parents:
5475
diff
changeset
|
140 /** |
d242fc975d65
(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 <Darkvater@openttd.org>
parents:
5475
diff
changeset
|
141 * A wrapper around opendir() which will convert the string from |
d242fc975d65
(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 <Darkvater@openttd.org>
parents:
5475
diff
changeset
|
142 * OPENTTD encoding to that of the filesystem. For all purposes this |
d242fc975d65
(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 <Darkvater@openttd.org>
parents:
5475
diff
changeset
|
143 * function behaves the same as the original opendir function |
d242fc975d65
(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 <Darkvater@openttd.org>
parents:
5475
diff
changeset
|
144 * @param path string to open directory of |
d242fc975d65
(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 <Darkvater@openttd.org>
parents:
5475
diff
changeset
|
145 * @return DIR pointer |
d242fc975d65
(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 <Darkvater@openttd.org>
parents:
5475
diff
changeset
|
146 */ |
d242fc975d65
(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 <Darkvater@openttd.org>
parents:
5475
diff
changeset
|
147 static inline DIR *ttd_opendir(const char *path) |
d242fc975d65
(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 <Darkvater@openttd.org>
parents:
5475
diff
changeset
|
148 { |
d242fc975d65
(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 <Darkvater@openttd.org>
parents:
5475
diff
changeset
|
149 return opendir(OTTD2FS(path)); |
d242fc975d65
(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 <Darkvater@openttd.org>
parents:
5475
diff
changeset
|
150 } |
d242fc975d65
(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 <Darkvater@openttd.org>
parents:
5475
diff
changeset
|
151 |
5475
eabf4b86aed6
(svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
152 #endif /* FIOS_H */ |