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 
23 
24  FT_INVALID = 7,
25  FT_NUMBITS = 3,
26  FT_MASK = (1 << FT_NUMBITS) - 1,
27 };
28 
31  /* Save game and scenario files. */
34 
35  /* Heightmap files. */
38 
39  /* fios 'files' */
44 
45  DFT_INVALID = 255,
46 };
47 
53 
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),
81 
82  FIOS_TYPE_INVALID = MAKE_FIOS_TYPE(FT_INVALID, DFT_INVALID),
83 };
84 
85 #undef MAKE_FIOS_TYPE
86 
93 {
94  return static_cast<AbstractFileType>(fios_type & FT_MASK);
95 }
96 
103 {
104  return static_cast<DetailedFileType>(fios_type >> FT_NUMBITS);
105 }
106 
128 };
129 
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
145  NUM_SEARCHPATHS
146 };
147 
149 
150 #endif /* FILEIO_TYPE_H */
FiosType
Elements of a file system that are recognized.
Definition: fileio_type.h:69
AbstractFileType
The different abstract types of files that the system knows about.
Definition: fileio_type.h:18
Old subdirectory for the music.
Definition: fileio_type.h:116
Subdirectory
The different kinds of subdirectories OpenTTD uses.
Definition: fileio_type.h:110
Number of subdirectories.
Definition: fileio_type.h:126
Search in the directory where the binary resides.
Definition: fileio_type.h:141
Subdirectory of scenario for heightmaps.
Definition: fileio_type.h:115
Subdirectory for all screenshots.
Definition: fileio_type.h:125
PNG file.
Definition: fileio_type.h:37
Subdirectory for all game scripts.
Definition: fileio_type.h:123
DetailedFileType GetDetailedFileType(FiosType fios_type)
Extract the detailed file type from a FiosType.
Definition: fileio_type.h:102
Searchpath
Types of searchpaths OpenTTD might use.
Definition: fileio_type.h:133
Subdirectory for all base data (base sets, intro game)
Definition: fileio_type.h:118
#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
A directory entry.
Definition: fileio_type.h:42
File is being saved.
Definition: fileio_type.h:52
Type (helpers) for enums.
Load file for checking and/or preview.
Definition: fileio_type.h:50
Save game or scenario file.
Definition: fileio_type.h:33
old or new savegame
Definition: fileio_type.h:20
old or new scenario
Definition: fileio_type.h:21
Base directory for all scenarios.
Definition: fileio_type.h:114
nothing to do
Definition: fileio_type.h:19
BMP file.
Definition: fileio_type.h:36
Number of bits required for storing a AbstractFileType value.
Definition: fileio_type.h:25
Old save game or scenario file.
Definition: fileio_type.h:32
Subdirectory for all translation files.
Definition: fileio_type.h:120
A path without any base directory.
Definition: fileio_type.h:127
Base directory for all savegames.
Definition: fileio_type.h:112
Subdirectory of save for autosaves.
Definition: fileio_type.h:113
Base directory for all subdirectories.
Definition: fileio_type.h:111
Subdirectory for all GS libraries.
Definition: fileio_type.h:124
Search within the autodownload directory.
Definition: fileio_type.h:144
AbstractFileType GetAbstractFileType(FiosType fios_type)
Extract the abstract file type from a FiosType.
Definition: fileio_type.h:92
File is being loaded.
Definition: fileio_type.h:51
SaveLoadOperation
Operation performed on the file.
Definition: fileio_type.h:49
Bitmask for extracting an abstract file type.
Definition: fileio_type.h:26
Subdirectory for all NewGRFs.
Definition: fileio_type.h:119
Direct filename.
Definition: fileio_type.h:43
Unknown or invalid file.
Definition: fileio_type.h:45
Subdirectory for all AI libraries.
Definition: fileio_type.h:122
Search in the personal directory.
Definition: fileio_type.h:139
A drive (letter) entry.
Definition: fileio_type.h:40
Invalid or unknown file type.
Definition: fileio_type.h:24
Subdirectory for all AI files.
Definition: fileio_type.h:121
A parent directory entry.
Definition: fileio_type.h:41
Search in the working directory.
Definition: fileio_type.h:135
Search in the installation directory.
Definition: fileio_type.h:142
heightmap file
Definition: fileio_type.h:22
Search within the application bundle.
Definition: fileio_type.h:143
#define DECLARE_POSTFIX_INCREMENT(type)
Some enums need to have allowed incrementing (i.e.
Definition: enum_type.hpp:16
DetailedFileType
Kinds of files in each AbstractFileType.
Definition: fileio_type.h:30
Search in the shared directory, like &#39;Shared Files&#39; under Windows.
Definition: fileio_type.h:140
Unknown file operation.
Definition: fileio_type.h:54
Old subdirectory for the data.
Definition: fileio_type.h:117