Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
Paths.h
Go to the documentation of this file.
1/* Copyright (C) 2025 Wildfire Games.
2 * This file is part of 0 A.D.
3 *
4 * 0 A.D. is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * 0 A.D. is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef INCLUDED_PS_GAMESETUP_PATHS
19#define INCLUDED_PS_GAMESETUP_PATHS
20
21#include "lib/os_path.h"
22
23class CmdLineArgs;
24
25/**
26 * Wrapper class for OS paths used by the game
27 */
28class Paths
29{
30public:
31 Paths(const CmdLineArgs& args);
32
33 /**
34 * Returns the game's root directory
35 */
36 const OsPath& Root() const
37 {
38 return m_root;
39 }
40
41 /**
42 * Returns directory for read-only data installed with the game
43 */
44 const OsPath& RData() const
45 {
46 return m_rdata;
47 }
48
49 /**
50 * Returns directory for game-managed data and mods
51 */
52 const OsPath& GameData() const
53 {
54 return m_gameData;
55 }
56
57 /**
58 * Returns directory for user-created data
59 * Only things created in response to an explicit user action should go here.
60 * (note: only Windows currently treats this differently than GameData)
61 */
62 const OsPath& UserData() const
63 {
64 return m_userData;
65 }
66
67 /**
68 * Returns config file directory
69 */
70 const OsPath& Config() const
71 {
72 return m_config;
73 }
74
75 /**
76 * Returns cache directory
77 */
78 const OsPath& Cache() const
79 {
80 return m_cache;
81 }
82
83 /**
84 * Returns logs directory
85 */
86 const OsPath& Logs() const
87 {
88 return m_logs;
89 }
90
91private:
92 static OsPath Root(const OsPath& argv0);
93 static OsPath RootData(const OsPath& argv0);
94 static OsPath XDG_Path(const char* envname, const OsPath& home, const OsPath& defaultPath);
95
96 // read-only directories, fixed paths relative to executable
99
100 // writable directories
105 OsPath m_logs; // special-cased in single-root-folder installations
106};
107
108#endif // #ifndef INCLUDED_PS_GAMESETUP_PATHS
Definition: CmdLineArgs.h:31
Definition: path.h:84
Wrapper class for OS paths used by the game.
Definition: Paths.h:29
const OsPath & Config() const
Returns config file directory.
Definition: Paths.h:70
static OsPath RootData(const OsPath &argv0)
Definition: Paths.cpp:203
const OsPath & UserData() const
Returns directory for user-created data Only things created in response to an explicit user action sh...
Definition: Paths.h:62
Paths(const CmdLineArgs &args)
Definition: Paths.cpp:46
OsPath m_logs
Definition: Paths.h:105
OsPath m_cache
Definition: Paths.h:104
const OsPath & Logs() const
Returns logs directory.
Definition: Paths.h:86
const OsPath & Root() const
Returns the game's root directory.
Definition: Paths.h:36
static OsPath XDG_Path(const char *envname, const OsPath &home, const OsPath &defaultPath)
Definition: Paths.cpp:228
OsPath m_gameData
Definition: Paths.h:101
OsPath m_rdata
Definition: Paths.h:98
const OsPath & GameData() const
Returns directory for game-managed data and mods.
Definition: Paths.h:52
OsPath m_userData
Definition: Paths.h:102
OsPath m_root
Definition: Paths.h:97
OsPath m_config
Definition: Paths.h:103
const OsPath & RData() const
Returns directory for read-only data installed with the game.
Definition: Paths.h:44
const OsPath & Cache() const
Returns cache directory.
Definition: Paths.h:78