Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
Paths.h
Go to the documentation of this file.
1/* Copyright (C) 2012 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#include "CmdLineArgs.h"
23
24/**
25 * Wrapper class for OS paths used by the game
26 */
27class Paths
28{
29public:
30 Paths(const CmdLineArgs& args);
31
32 /**
33 * Returns the game's root directory
34 */
35 const OsPath& Root() const
36 {
37 return m_root;
38 }
39
40 /**
41 * Returns directory for read-only data installed with the game
42 */
43 const OsPath& RData() const
44 {
45 return m_rdata;
46 }
47
48 /**
49 * Returns directory for game-managed data and mods
50 */
51 const OsPath& GameData() const
52 {
53 return m_gameData;
54 }
55
56 /**
57 * Returns directory for user-created data
58 * Only things created in response to an explicit user action should go here.
59 * (note: only Windows currently treats this differently than GameData)
60 */
61 const OsPath& UserData() const
62 {
63 return m_userData;
64 }
65
66 /**
67 * Returns config file directory
68 */
69 const OsPath& Config() const
70 {
71 return m_config;
72 }
73
74 /**
75 * Returns cache directory
76 */
77 const OsPath& Cache() const
78 {
79 return m_cache;
80 }
81
82 /**
83 * Returns logs directory
84 */
85 const OsPath& Logs() const
86 {
87 return m_logs;
88 }
89
90private:
91 static OsPath Root(const OsPath& argv0);
92 static OsPath RootData(const OsPath& argv0);
93 static OsPath XDG_Path(const char* envname, const OsPath& home, const OsPath& defaultPath);
94
95 // read-only directories, fixed paths relative to executable
98
99 // writable directories
104 OsPath m_logs; // special-cased in single-root-folder installations
105};
106
107#endif // #ifndef INCLUDED_PS_GAMESETUP_PATHS
Definition: CmdLineArgs.h:29
Definition: path.h:80
Wrapper class for OS paths used by the game.
Definition: Paths.h:28
const OsPath & Config() const
Returns config file directory.
Definition: Paths.h:69
static OsPath RootData(const OsPath &argv0)
Definition: Paths.cpp:186
const OsPath & UserData() const
Returns directory for user-created data Only things created in response to an explicit user action sh...
Definition: Paths.h:61
Paths(const CmdLineArgs &args)
Definition: Paths.cpp:33
OsPath m_logs
Definition: Paths.h:104
OsPath m_cache
Definition: Paths.h:103
const OsPath & Logs() const
Returns logs directory.
Definition: Paths.h:85
const OsPath & Root() const
Returns the game's root directory.
Definition: Paths.h:35
static OsPath XDG_Path(const char *envname, const OsPath &home, const OsPath &defaultPath)
Definition: Paths.cpp:212
OsPath m_gameData
Definition: Paths.h:100
OsPath m_rdata
Definition: Paths.h:97
const OsPath & GameData() const
Returns directory for game-managed data and mods.
Definition: Paths.h:51
OsPath m_userData
Definition: Paths.h:101
OsPath m_root
Definition: Paths.h:96
OsPath m_config
Definition: Paths.h:102
const OsPath & RData() const
Returns directory for read-only data installed with the game.
Definition: Paths.h:43
const OsPath & Cache() const
Returns cache directory.
Definition: Paths.h:77