OpenTTD

fileio_type.h
Go to the documentation of this file.
1 /* $Id: fileio_type.h 27653 2016-09-04 16:06:50Z alberth $ */
2
3 /*
4 * This file is part of OpenTTD.
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8 */
9
12 #ifndef FILEIO_TYPE_H
13 #define FILEIO_TYPE_H
14
15 #include "core/enum_type.hpp"
16
18 enum AbstractFileType {
19 FT_NONE,
20 FT_SAVEGAME,
21 FT_SCENARIO,
22 FT_HEIGHTMAP,
23
24 FT_INVALID = 7,
25 FT_NUMBITS = 3,
26 FT_MASK = (1 << FT_NUMBITS) - 1,
27 };
28
30 enum DetailedFileType {
31 /* Save game and scenario files. */
32 DFT_OLD_GAME_FILE,
33 DFT_GAME_FILE,
34
35 /* Heightmap files. */
36 DFT_HEIGHTMAP_BMP,
37 DFT_HEIGHTMAP_PNG,
38
39 /* fios 'files' */
40 DFT_FIOS_DRIVE,
41 DFT_FIOS_PARENT,
42 DFT_FIOS_DIR,
43 DFT_FIOS_DIRECT,
44
45 DFT_INVALID = 255,
46 };
47
49 enum SaveLoadOperation {
50 SLO_CHECK,
51 SLO_LOAD,
52 SLO_SAVE,
53
54 SLO_INVALID,
55 };
56
62 #define MAKE_FIOS_TYPE(abstract, detailed) ((abstract) | ((detailed) << FT_NUMBITS))
63
69 enum FiosType {
70 FIOS_TYPE_DRIVE = MAKE_FIOS_TYPE(FT_NONE, DFT_FIOS_DRIVE),
71 FIOS_TYPE_PARENT = MAKE_FIOS_TYPE(FT_NONE, DFT_FIOS_PARENT),
72 FIOS_TYPE_DIR = MAKE_FIOS_TYPE(FT_NONE, DFT_FIOS_DIR),
73 FIOS_TYPE_DIRECT = MAKE_FIOS_TYPE(FT_NONE, DFT_FIOS_DIRECT),
74
75 FIOS_TYPE_FILE = MAKE_FIOS_TYPE(FT_SAVEGAME, DFT_GAME_FILE),
76 FIOS_TYPE_OLDFILE = MAKE_FIOS_TYPE(FT_SAVEGAME, DFT_OLD_GAME_FILE),
77 FIOS_TYPE_SCENARIO = MAKE_FIOS_TYPE(FT_SCENARIO, DFT_GAME_FILE),
78 FIOS_TYPE_OLD_SCENARIO = MAKE_FIOS_TYPE(FT_SCENARIO, DFT_OLD_GAME_FILE),
79 FIOS_TYPE_PNG = MAKE_FIOS_TYPE(FT_HEIGHTMAP, DFT_HEIGHTMAP_PNG),
80 FIOS_TYPE_BMP = MAKE_FIOS_TYPE(FT_HEIGHTMAP, DFT_HEIGHTMAP_BMP),
81
82 FIOS_TYPE_INVALID = MAKE_FIOS_TYPE(FT_INVALID, DFT_INVALID),
83 };
84
85 #undef MAKE_FIOS_TYPE
86
92 inline AbstractFileType GetAbstractFileType(FiosType fios_type)
93 {
94 return static_cast<AbstractFileType>(fios_type & FT_MASK);
95 }
96
102 inline DetailedFileType GetDetailedFileType(FiosType fios_type)
103 {
104 return static_cast<DetailedFileType>(fios_type >> FT_NUMBITS);
105 }
106
110 enum Subdirectory {
111 BASE_DIR,
112 SAVE_DIR,
113 AUTOSAVE_DIR,
114 SCENARIO_DIR,
115 HEIGHTMAP_DIR,
116 OLD_GM_DIR,
117 OLD_DATA_DIR,
118 BASESET_DIR,
119 NEWGRF_DIR,
120 LANG_DIR,
121 AI_DIR,
122 AI_LIBRARY_DIR,
123 GAME_DIR,
124 GAME_LIBRARY_DIR,
125 SCREENSHOT_DIR,
126 NUM_SUBDIRS,
127 NO_DIRECTORY,
128 };
129
133 enum Searchpath {
134 SP_FIRST_DIR,
135 SP_WORKING_DIR = SP_FIRST_DIR,
136 #if defined(WITH_XDG_BASEDIR) && defined(WITH_PERSONAL_DIR)
137 SP_PERSONAL_DIR_XDG,
138 #endif
139 SP_PERSONAL_DIR,
140 SP_SHARED_DIR,
141 SP_BINARY_DIR,
142 SP_INSTALLATION_DIR,
143 SP_APPLICATION_BUNDLE_DIR,
144 SP_AUTODOWNLOAD_DIR,
145 NUM_SEARCHPATHS
146 };
147
148 DECLARE_POSTFIX_INCREMENT(Searchpath)
149
150 #endif /* FILEIO_TYPE_H */
FiosType
FiosType
Elements of a file system that are recognized.
Definition: fileio_type.h:69
AbstractFileType
AbstractFileType
The different abstract types of files that the system knows about.
Definition: fileio_type.h:18
OLD_GM_DIR
Old subdirectory for the music.
Definition: fileio_type.h:116
Subdirectory
Subdirectory
The different kinds of subdirectories OpenTTD uses.
Definition: fileio_type.h:110
NUM_SUBDIRS
Number of subdirectories.
Definition: fileio_type.h:126
SP_BINARY_DIR
Search in the directory where the binary resides.
Definition: fileio_type.h:141
HEIGHTMAP_DIR
Subdirectory of scenario for heightmaps.
Definition: fileio_type.h:115
SCREENSHOT_DIR
Subdirectory for all screenshots.
Definition: fileio_type.h:125
DFT_HEIGHTMAP_PNG
PNG file.
Definition: fileio_type.h:37
GAME_DIR
Subdirectory for all game scripts.
Definition: fileio_type.h:123
GetDetailedFileType
DetailedFileType GetDetailedFileType(FiosType fios_type)
Extract the detailed file type from a FiosType.
Definition: fileio_type.h:102
Searchpath
Searchpath
Types of searchpaths OpenTTD might use.
Definition: fileio_type.h:133
BASESET_DIR
Subdirectory for all base data (base sets, intro game)
Definition: fileio_type.h:118
MAKE_FIOS_TYPE
#define MAKE_FIOS_TYPE(abstract, detailed)
Construct an enum value for FiosType as a combination of an abstract and a detailed file type...
Definition: fileio_type.h:62
DFT_FIOS_DIR
A directory entry.
Definition: fileio_type.h:42
SLO_SAVE
File is being saved.
Definition: fileio_type.h:52
enum_type.hpp
Type (helpers) for enums.
SLO_CHECK
Load file for checking and/or preview.
Definition: fileio_type.h:50
DFT_GAME_FILE
Save game or scenario file.
Definition: fileio_type.h:33
FT_SAVEGAME
old or new savegame
Definition: fileio_type.h:20
FT_SCENARIO
old or new scenario
Definition: fileio_type.h:21
SCENARIO_DIR
Base directory for all scenarios.
Definition: fileio_type.h:114
FT_NONE
nothing to do
Definition: fileio_type.h:19
DFT_HEIGHTMAP_BMP
BMP file.
Definition: fileio_type.h:36
FT_NUMBITS
Number of bits required for storing a AbstractFileType value.
Definition: fileio_type.h:25
DFT_OLD_GAME_FILE
Old save game or scenario file.
Definition: fileio_type.h:32
LANG_DIR
Subdirectory for all translation files.
Definition: fileio_type.h:120
NO_DIRECTORY
A path without any base directory.
Definition: fileio_type.h:127
SAVE_DIR
Base directory for all savegames.
Definition: fileio_type.h:112
AUTOSAVE_DIR
Subdirectory of save for autosaves.
Definition: fileio_type.h:113
BASE_DIR
Base directory for all subdirectories.
Definition: fileio_type.h:111
GAME_LIBRARY_DIR
Subdirectory for all GS libraries.
Definition: fileio_type.h:124
SP_AUTODOWNLOAD_DIR
Search within the autodownload directory.
Definition: fileio_type.h:144
GetAbstractFileType
AbstractFileType GetAbstractFileType(FiosType fios_type)
Extract the abstract file type from a FiosType.
Definition: fileio_type.h:92
SLO_LOAD
File is being loaded.
Definition: fileio_type.h:51
SaveLoadOperation
SaveLoadOperation
Operation performed on the file.
Definition: fileio_type.h:49
FT_MASK
Bitmask for extracting an abstract file type.
Definition: fileio_type.h:26
NEWGRF_DIR
Subdirectory for all NewGRFs.
Definition: fileio_type.h:119
DFT_FIOS_DIRECT
Direct filename.
Definition: fileio_type.h:43
DFT_INVALID
Unknown or invalid file.
Definition: fileio_type.h:45
AI_LIBRARY_DIR
Subdirectory for all AI libraries.
Definition: fileio_type.h:122
SP_PERSONAL_DIR
Search in the personal directory.
Definition: fileio_type.h:139
DFT_FIOS_DRIVE
A drive (letter) entry.
Definition: fileio_type.h:40
FT_INVALID
Invalid or unknown file type.
Definition: fileio_type.h:24
AI_DIR
Subdirectory for all AI files.
Definition: fileio_type.h:121
DFT_FIOS_PARENT
A parent directory entry.
Definition: fileio_type.h:41
SP_WORKING_DIR
Search in the working directory.
Definition: fileio_type.h:135
SP_INSTALLATION_DIR
Search in the installation directory.
Definition: fileio_type.h:142
FT_HEIGHTMAP
heightmap file
Definition: fileio_type.h:22
SP_APPLICATION_BUNDLE_DIR
Search within the application bundle.
Definition: fileio_type.h:143
DECLARE_POSTFIX_INCREMENT
#define DECLARE_POSTFIX_INCREMENT(type)
Some enums need to have allowed incrementing (i.e.
Definition: enum_type.hpp:16
DetailedFileType
DetailedFileType
Kinds of files in each AbstractFileType.
Definition: fileio_type.h:30
SP_SHARED_DIR
Search in the shared directory, like &#39;Shared Files&#39; under Windows.
Definition: fileio_type.h:140
SLO_INVALID
Unknown file operation.
Definition: fileio_type.h:54
OLD_DATA_DIR
Old subdirectory for the data.
Definition: fileio_type.h:117