18 #include "precompiled.h"
39 const char* subdirectoryName = args.
Has(
"writableRoot")? 0 :
"0ad";
63 m_logs = appdata/
"logs"/
"";
88 m_cache = localAppdata /
"cache"/
"";
91 m_config = roamingAppData /
"config"/
"";
92 m_logs = localAppdata /
"logs"/
"";
120 appSupportPath =
OsPath(path) / subdirectoryName;
125 cachePath =
OsPath(path) / subdirectoryName;
132 m_config = appSupportPath /
"config"/
"";
133 m_logs = appSupportPath /
"logs"/
"";
137 const char* envHome = getenv(
"HOME");
139 const OsPath home(envHome);
140 const OsPath xdgData =
XDG_Path(
"XDG_DATA_HOME", home, home/
".local/share/") / subdirectoryName;
141 const OsPath xdgConfig =
XDG_Path(
"XDG_CONFIG_HOME", home, home/
".config/" ) / subdirectoryName;
142 const OsPath xdgCache =
XDG_Path(
"XDG_CACHE_HOME", home, home/
".cache/" ) / subdirectoryName;
149 m_logs = xdgConfig /
"logs"/
"";
159 return OsPath(
"/sdcard/0ad");
175 LOGERROR(L
"Cannot find executable (expected at '%ls')", pathname.
string().c_str());
179 for(
size_t i = 0; i < 2; i++)
180 pathname = pathname.
Parent();
189 #ifdef INSTALLED_DATADIR
201 ENSURE(!resourcesPath.empty());
203 return OsPath(resourcesPath)/
"data"/
"";
207 return Root(argv0)/
"data"/
"";
209 #endif // INSTALLED_DATADIR
214 const char* path = getenv(envname);
216 if(path && path[0] !=
'\0')
219 return home / path/
"";
222 return defaultPath/
"";
#define WARN_IF_ERR(expression)
bool osx_IsAppBundleValid()
Check if app is running in a valid bundle.
OsPath GetArg0() const
Get the value of argv[0], which is typically meant to be the name/path of the program (but the actual...
const OsPath & Root() const
Returns the game's root directory.
Paths(const CmdLineArgs &args)
C++ interface to Cocoa implementation for getting bundle information.
bool FileExists(const OsPath &pathname)
const OsPath & wutil_RoamingAppdataPath()
const OsPath & wutil_LocalAppdataPath()
#define ENSURE(expr)
ensure the expression <expr> evaluates to non-zero.
#define UNUSED2(param)
mark a function local variable or parameter as unused and avoid the corresponding compiler warning...
static OsPath XDG_Path(const char *envname, const OsPath &home, const OsPath &defaultPath)
bool Has(const char *name) const
Test whether the given name was specified, as either -name or -name=value
const String & string() const
LIB_API OsPath wrealpath(const OsPath &pathname)
std::string osx_GetCachesPath()
Get the user's Caches path (typically ~/Library/Caches)
static OsPath RootData(const OsPath &argv0)
OsPath sys_ExecutablePathname()
std::string osx_GetAppSupportPath()
Get the user's Application Support path (typically ~/Library/Application Support) ...
std::string osx_GetBundleResourcesPath()
Get the system path to the bundle's Resources directory.
const OsPath & wutil_PersonalPath()
void debug_printf(const wchar_t *fmt,...)
write a formatted string to the debug channel, subject to filtering (see below).
C++ interface to Cocoa implementation for retrieving standard OS X paths.