Ticket #1145: windows_osx_path+bundle_fixes-03212012.patch
File windows_osx_path+bundle_fixes-03212012.patch, 25.6 KB (added by , 12 years ago) |
---|
-
source/lib/sysdep/os/osx/osx_bundle.h
1 /* Copyright (c) 2012 Wildfire Games 2 * 3 * Permission is hereby granted, free of charge, to any person obtaining 4 * a copy of this software and associated documentation files (the 5 * "Software"), to deal in the Software without restriction, including 6 * without limitation the rights to use, copy, modify, merge, publish, 7 * distribute, sublicense, and/or sell copies of the Software, and to 8 * permit persons to whom the Software is furnished to do so, subject to 9 * the following conditions: 10 * 11 * The above copyright notice and this permission notice shall be included 12 * in all copies or substantial portions of the Software. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 18 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 19 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 20 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 */ 22 23 #ifndef OSX_BUNDLE_H 24 #define OSX_BUNDLE_H 25 26 /** 27 * @file 28 * C++ interface to Cocoa implementation for getting bundle information 29 */ 30 31 /** 32 * Check if app is running in a valid bundle 33 * 34 * @return true if valid bundle reference was found matching identifier 35 * property "com.wildfiregames.0ad" 36 */ 37 bool osx_IsAppBundleValid(); 38 39 /** 40 * Get the system path to the bundle's Resources directory 41 * 42 * @return string containing POSIX-style path in UTF-8 encoding, 43 * else empty string if an error occurred. 44 */ 45 std::string osx_GetBundleResourcesPath(); 46 47 /** 48 * Get the system path to the bundle's Frameworks directory 49 * 50 * @return string containing POSIX-style path in UTF-8 encoding, 51 * else empty string if an error occurred. 52 */ 53 std::string osx_GetBundleFrameworksPath(); 54 55 #endif // OSX_BUNDLE_H -
source/lib/sysdep/os/osx/osx_bundle.h
-
source/lib/sysdep/os/osx/osx_bundle.mm
Property changes on: source/lib/sysdep/os/osx/osx_bundle.h ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native
1 /* Copyright (c) 2012 Wildfire Games 2 * 3 * Permission is hereby granted, free of charge, to any person obtaining 4 * a copy of this software and associated documentation files (the 5 * "Software"), to deal in the Software without restriction, including 6 * without limitation the rights to use, copy, modify, merge, publish, 7 * distribute, sublicense, and/or sell copies of the Software, and to 8 * permit persons to whom the Software is furnished to do so, subject to 9 * the following conditions: 10 * 11 * The above copyright notice and this permission notice shall be included 12 * in all copies or substantial portions of the Software. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 18 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 19 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 20 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 */ 22 23 #import <Foundation/Foundation.h> 24 #import <string> 25 26 #import "osx_bundle.h" 27 28 #define STRINGIZE2(id) # id 29 #define STRINGIZE(id) STRINGIZE2(id) 30 31 // Pass the bundle identifier string as a build option 32 #ifdef BUNDLE_IDENTIFIER 33 static const char* BUNDLE_ID_STR = STRINGIZE(BUNDLE_IDENTIFIER); 34 #else 35 static const char* BUNDLE_ID_STR = ""; 36 #endif 37 38 39 bool osx_IsAppBundleValid() 40 { 41 // Check for the existence of bundle with correct identifier property 42 // (can't just use mainBundle because that can return a bundle reference 43 // even for a loose binary!) 44 NSBundle *bundle = [NSBundle bundleWithIdentifier: [NSString stringWithUTF8String: BUNDLE_ID_STR]]; 45 46 return bundle != nil; 47 } 48 49 std::string osx_GetBundleResourcesPath() 50 { 51 std::string path; 52 53 NSBundle *bundle = [NSBundle bundleWithIdentifier: [NSString stringWithUTF8String: BUNDLE_ID_STR]]; 54 if (bundle != nil) 55 { 56 // Retrieve NSURL and convert to POSIX path, then get C-string 57 // encoded as UTF-8, and use it to construct std::string 58 // NSURL:path "If the receiver does not conform to RFC 1808, returns nil." 59 NSString *pathStr = [[bundle resourceURL] path]; 60 if (pathStr != nil) 61 { 62 path = std::string([pathStr UTF8String]); 63 } 64 } 65 66 return path; 67 } 68 69 std::string osx_GetBundleFrameworksPath() 70 { 71 std::string path; 72 73 NSBundle *bundle = [NSBundle bundleWithIdentifier: [NSString stringWithUTF8String: BUNDLE_ID_STR]]; 74 if (bundle != nil) 75 { 76 // Retrieve NSURL and convert to POSIX path, then get C-string 77 // encoded as UTF-8, and use it to construct std::string 78 // NSURL:path "If the receiver does not conform to RFC 1808, returns nil." 79 NSString *pathStr = [[bundle privateFrameworksURL] path]; 80 if (pathStr != nil) 81 { 82 path = std::string([pathStr UTF8String]); 83 } 84 } 85 86 return path; 87 } -
source/lib/sysdep/os/osx/osx_bundle.mm
-
source/lib/sysdep/os/osx/osx_paths.h
Property changes on: source/lib/sysdep/os/osx/osx_bundle.mm ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native
1 /* Copyright (c) 2012 Wildfire Games 2 * 3 * Permission is hereby granted, free of charge, to any person obtaining 4 * a copy of this software and associated documentation files (the 5 * "Software"), to deal in the Software without restriction, including 6 * without limitation the rights to use, copy, modify, merge, publish, 7 * distribute, sublicense, and/or sell copies of the Software, and to 8 * permit persons to whom the Software is furnished to do so, subject to 9 * the following conditions: 10 * 11 * The above copyright notice and this permission notice shall be included 12 * in all copies or substantial portions of the Software. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 18 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 19 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 20 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 */ 22 23 #ifndef OSX_PATHS_H 24 #define OSX_PATHS_H 25 26 /** 27 * @file 28 * C++ interface to Cocoa implementation for retrieving standard OS X paths 29 */ 30 31 /** 32 * Get the user's Application Support path (typically ~/Library/Application Support) 33 * 34 * @return string containing POSIX-style path in UTF-8 encoding, 35 * else empty string if an error occurred. 36 */ 37 std::string osx_GetAppSupportPath(); 38 39 /** 40 * Get the user's Caches path (typically ~/Library/Caches) 41 * 42 * @return string containing POSIX-style path in UTF-8 encoding, 43 * else empty string if an error occurred. 44 */ 45 std::string osx_GetCachesPath(); 46 47 #endif // OSX_PATHS_H -
source/lib/sysdep/os/osx/osx_paths.h
-
source/lib/sysdep/os/osx/osx_paths.mm
Property changes on: source/lib/sysdep/os/osx/osx_paths.h ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native
1 /* Copyright (c) 2012 Wildfire Games 2 * 3 * Permission is hereby granted, free of charge, to any person obtaining 4 * a copy of this software and associated documentation files (the 5 * "Software"), to deal in the Software without restriction, including 6 * without limitation the rights to use, copy, modify, merge, publish, 7 * distribute, sublicense, and/or sell copies of the Software, and to 8 * permit persons to whom the Software is furnished to do so, subject to 9 * the following conditions: 10 * 11 * The above copyright notice and this permission notice shall be included 12 * in all copies or substantial portions of the Software. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 18 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 19 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 20 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 */ 22 23 #import <Foundation/Foundation.h> 24 #import <string> 25 26 #import "osx_paths.h" 27 28 // Helper function 29 static std::string getUserDirectoryPath(NSSearchPathDirectory directory) 30 { 31 std::string result; 32 33 // Returns array of NSURL objects which are preferred for file paths 34 NSArray* paths = [[NSFileManager defaultManager] URLsForDirectory:directory inDomains:NSUserDomainMask]; 35 if ([paths count] > 0) 36 { 37 // Retrieve first NSURL and convert to POSIX path, then get C-string 38 // encoded as UTF-8, and use it to construct std::string 39 // NSURL:path "If the receiver does not conform to RFC 1808, returns nil." 40 NSString* pathStr = [[paths objectAtIndex:0] path]; 41 if (pathStr != nil) 42 result = std::string([pathStr UTF8String]); 43 } 44 45 return result; 46 } 47 48 std::string osx_GetAppSupportPath() 49 { 50 return getUserDirectoryPath(NSApplicationSupportDirectory); 51 } 52 53 std::string osx_GetCachesPath() 54 { 55 return getUserDirectoryPath(NSCachesDirectory); 56 } -
source/lib/sysdep/os/osx/osx_paths.mm
-
source/lib/sysdep/os/win/wutil.cpp
Property changes on: source/lib/sysdep/os/osx/osx_paths.mm ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native
1 /* Copyright (c) 201 0Wildfire Games1 /* Copyright (c) 2012 Wildfire Games 2 2 * 3 3 * Permission is hereby granted, free of charge, to any person obtaining 4 4 * a copy of this software and associated documentation files (the … … 251 251 // (NB: wutil_Init is called before static ctors => use placement new) 252 252 static OsPath* systemPath; 253 253 static OsPath* executablePath; 254 static OsPath* appdataPath; 254 static OsPath* localAppdataPath; 255 static OsPath* roamingAppdataPath; 256 static OsPath* personalPath; 255 257 256 258 const OsPath& wutil_SystemPath() 257 259 { … … 263 265 return *executablePath; 264 266 } 265 267 266 const OsPath& wutil_ AppdataPath()268 const OsPath& wutil_LocalAppdataPath() 267 269 { 268 return * appdataPath;270 return *localAppdataPath; 269 271 } 270 272 273 const OsPath& wutil_RoamingAppdataPath() 274 { 275 return *roamingAppdataPath; 276 } 271 277 278 const OsPath& wutil_PersonalPath() 279 { 280 return *personalPath; 281 } 282 283 // Helper to avoid duplicating this setup 284 static OsPath* GetFolderPath(int csidl) 285 { 286 HWND hwnd = 0; // ignored unless a dial-up connection is needed to access the folder 287 HANDLE token = 0; 288 wchar_t path[MAX_PATH]; // mandated by SHGetFolderPathW 289 const HRESULT ret = SHGetFolderPathW(hwnd, csidl, token, 0, path); 290 ENSURE(SUCCEEDED(ret)); 291 if(GetLastError() == ERROR_NO_TOKEN) // avoid polluting last error 292 SetLastError(0); 293 return new(wutil_Allocate(sizeof(OsPath))) OsPath(path); 294 } 295 272 296 static void GetDirectories() 273 297 { 274 298 WinScopedPreserveLastError s; … … 286 310 // executable's directory 287 311 executablePath = new(wutil_Allocate(sizeof(OsPath))) OsPath(sys_ExecutablePathname().Parent()); 288 312 289 // application data 290 { 291 HWND hwnd = 0; // ignored unless a dial-up connection is needed to access the folder 292 HANDLE token = 0; 293 wchar_t path[MAX_PATH]; // mandated by SHGetFolderPathW 294 const HRESULT ret = SHGetFolderPathW(hwnd, CSIDL_APPDATA, token, 0, path); 295 ENSURE(SUCCEEDED(ret)); 296 if(GetLastError() == ERROR_NO_TOKEN) // avoid polluting last error 297 SetLastError(0); 298 appdataPath = new(wutil_Allocate(sizeof(OsPath))) OsPath(path); 299 } 313 // roaming application data 314 roamingAppdataPath = GetFolderPath(CSIDL_APPDATA); 315 316 // local application data 317 localAppdataPath = GetFolderPath(CSIDL_LOCAL_APPDATA); 318 319 // my documents 320 personalPath = GetFolderPath(CSIDL_PERSONAL); 300 321 } 301 322 302 323 … … 306 327 wutil_Free(systemPath); 307 328 executablePath->~OsPath(); 308 329 wutil_Free(executablePath); 309 appdataPath->~OsPath(); 310 wutil_Free(appdataPath); 330 localAppdataPath->~OsPath(); 331 wutil_Free(localAppdataPath); 332 roamingAppdataPath->~OsPath(); 333 wutil_Free(roamingAppdataPath); 334 personalPath->~OsPath(); 335 wutil_Free(personalPath); 311 336 } 312 337 313 338 -
source/lib/sysdep/os/win/wutil.h
1 /* Copyright (c) 201 0Wildfire Games1 /* Copyright (c) 2012 Wildfire Games 2 2 * 3 3 * Permission is hereby granted, free of charge, to any person obtaining 4 4 * a copy of this software and associated documentation files (the … … 159 159 160 160 extern const OsPath& wutil_SystemPath(); 161 161 extern const OsPath& wutil_ExecutablePath(); 162 extern const OsPath& wutil_AppdataPath(); 162 extern const OsPath& wutil_LocalAppdataPath(); 163 extern const OsPath& wutil_RoamingAppdataPath(); 164 extern const OsPath& wutil_PersonalPath(); 163 165 164 166 165 167 //----------------------------------------------------------------------------- -
source/ps/DllLoader.cpp
1 /* Copyright (C) 201 1Wildfire Games.1 /* Copyright (C) 2012 Wildfire Games. 2 2 * This file is part of 0 A.D. 3 3 * 4 4 * 0 A.D. is free software: you can redistribute it and/or modify … … 25 25 #include "ps/CLogger.h" 26 26 #include "ps/GameSetup/Config.h" 27 27 28 #if OS_MACOSX 29 # include "lib/sysdep/os/osx/osx_bundle.h" 30 #endif 31 28 32 static void* const HANDLE_UNAVAILABLE = (void*)-1; 29 33 30 34 // directory to search for libraries (optionally set by --libdir at build-time, … … 70 74 static CStr GenerateFilename(const CStr& name, const CStr& suffix, const CStr& extension) 71 75 { 72 76 CStr n; 77 73 78 if (!g_Libdir.empty()) 74 79 n = g_Libdir + "/"; 80 81 #if OS_MACOSX 82 // On OS X, we might be in a bundle in which case the lib directory is ../Frameworks 83 // relative to the binary, so we use a helper function to get the system path 84 if (osx_IsAppBundleValid()) 85 { 86 CStr frameworksPath = osx_GetBundleFrameworksPath(); 87 if (!frameworksPath.empty()) 88 { 89 n = frameworksPath + "/"; 90 } 91 } 92 #endif 93 75 94 n += prefix + name + suffix + extension; 76 95 return n; 77 96 } -
source/ps/GameSetup/GameSetup.cpp
453 453 const size_t cacheSize = ChooseCacheSize(); 454 454 g_VFS = CreateVfs(cacheSize); 455 455 456 g_VFS->Mount(L"screenshots/", paths. Data()/"screenshots"/"");457 g_VFS->Mount(L"saves/", paths. Data()/"saves"/"", VFS_MOUNT_WATCH);456 g_VFS->Mount(L"screenshots/", paths.UserData()/"screenshots"/""); 457 g_VFS->Mount(L"saves/", paths.UserData()/"saves"/"", VFS_MOUNT_WATCH); 458 458 const OsPath readonlyConfig = paths.RData()/"config"/""; 459 459 g_VFS->Mount(L"config/", readonlyConfig); 460 460 if(readonlyConfig != paths.Config()) -
source/ps/GameSetup/Paths.cpp
1 /* Copyright (C) 20 09Wildfire Games.1 /* Copyright (C) 2012 Wildfire Games. 2 2 * This file is part of 0 A.D. 3 3 * 4 4 * 0 A.D. is free software: you can redistribute it and/or modify … … 22 22 #include "lib/sysdep/sysdep.h" // sys_get_executable_name 23 23 #include "lib/sysdep/filesystem.h" // wrealpath 24 24 #if OS_WIN 25 # include "lib/sysdep/os/win/wutil.h" // wutil_AppdataPath 25 # include "lib/sysdep/os/win/wutil.h" // wutil_*Path 26 #elif OS_MACOSX 27 # include "lib/sysdep/os/osx/osx_paths.h" 28 # include "lib/sysdep/os/osx/osx_bundle.h" 26 29 #endif 27 30 #include "ps/CLogger.h" 28 31 … … 31 34 { 32 35 m_root = Root(args.GetArg0()); 33 36 34 #ifdef INSTALLED_DATADIR 35 m_rdata = OsPath(STRINGIZE(INSTALLED_DATADIR))/""; 36 #else 37 m_rdata = m_root/"data"/""; 38 #endif 37 m_rdata = RootData(args.GetArg0()); 39 38 40 39 const char* subdirectoryName = args.Has("writableRoot")? 0 : "0ad"; 41 40 42 // everything is a subdirectory of the root43 41 if(!subdirectoryName) 44 42 { 45 m_data = m_rdata; 46 m_config = m_data/"config"/""; 47 m_cache = m_data/"cache"/""; 48 m_logs = m_root/"logs"/""; 43 // Note: if writableRoot option is passed to the game, then 44 // all the data is a subdirectory of the root 45 m_gameData = m_rdata; 46 m_userData = m_gameData; 47 m_config = m_gameData / "config"/""; 48 m_cache = m_gameData / "cache"/""; 49 m_logs = m_root / "logs"/""; 49 50 } 50 else 51 else // OS-specific path handling 51 52 { 53 52 54 #if OS_ANDROID 55 53 56 const OsPath appdata = OsPath("/sdcard/0ad/appdata"); 54 m_data = appdata/"data"/""; 57 58 // We don't make the game vs. user data distinction on Android 59 m_gameData = appdata/"data"/""; 60 m_userData = m_gameData; 55 61 m_config = appdata/"config"/""; 56 62 m_cache = appdata/"cache"/""; 57 63 m_logs = appdata/"logs"/""; 64 58 65 #elif OS_WIN 59 const OsPath appdata = wutil_AppdataPath() / subdirectoryName/""; 60 m_data = appdata/"data"/""; 61 m_config = appdata/"config"/""; 62 m_cache = appdata/"cache"/""; 63 m_logs = appdata/"logs"/""; 64 #else 66 67 /* For reasoning behind our Windows paths, see the discussion here: 68 * http://www.wildfiregames.com/forum/index.php?showtopic=14759 69 * 70 * Summary: 71 * 1. Local appdata: for bulky unfriendly data like the cache, 72 * which can be recreated if deleted; doesn't need backing up. 73 * 2. Roaming appdata: for slightly less unfriendly data like config 74 * files that might theoretically be shared between different 75 * machines on a domain. 76 * 3. Personal / My Documents: for data explicitly created by the user, 77 * and which should be visible and easily accessed. We use a non- 78 * localized My Games subfolder for improved organization. 79 */ 80 81 // %localappdata%/0ad/ 82 const OsPath localAppdata = wutil_LocalAppdataPath() / subdirectoryName/""; 83 // %appdata%/0ad/ 84 const OsPath roamingAppData = wutil_RoamingAppdataPath() / subdirectoryName/""; 85 // My Documents/My Games/0ad/ 86 const OsPath personalData = wutil_PersonalPath() / "My Games" / subdirectoryName/""; 87 88 m_cache = localAppdata / "cache"/""; 89 m_gameData = roamingAppData / "data"/""; 90 m_userData = personalData/""; 91 m_config = roamingAppData / "config"/""; 92 m_logs = localAppdata / "logs"/""; 93 94 #elif OS_MACOSX 95 96 /* For reasoning behind our OS X paths, see the discussion here: 97 * http://www.wildfiregames.com/forum/index.php?showtopic=15511 98 * 99 * Summary: 100 * 1. Application Support: most data associated with the app 101 * should be stored here, with few exceptions (e.g. temporary 102 * data, cached data, and managed media files). 103 * 2. Caches: used for non-critial app data that can be easily 104 * regenerated if this directory is deleted. It is not 105 * included in backups by default. 106 * 107 * Note: the paths returned by osx_Get*Path are not guaranteed to exist, 108 * but that's OK since we always create them on demand. 109 */ 110 111 // We probably want to use the same subdirectoryName regardless 112 // of whether running a bundle or from SVN. Apple recommends using 113 // company name, bundle name or bundle identifier. 114 OsPath appSupportPath; // ~/Library/Application Support/0ad 115 OsPath cachePath; // ~/Library/Caches/0ad 116 117 { 118 std::string path = osx_GetAppSupportPath(); 119 ENSURE(!path.empty()); 120 appSupportPath = OsPath(path) / subdirectoryName; 121 } 122 { 123 std::string path = osx_GetCachesPath(); 124 ENSURE(!path.empty()); 125 cachePath = OsPath(path) / subdirectoryName; 126 } 127 128 // We don't make the game vs. user data distinction on OS X 129 m_gameData = appSupportPath / "data"/""; 130 m_userData = m_gameData; 131 m_cache = cachePath/""; 132 m_config = appSupportPath / "config"/""; 133 m_logs = appSupportPath / "logs"/""; 134 135 #else // OS_UNIX 136 65 137 const char* envHome = getenv("HOME"); 66 138 ENSURE(envHome); 67 139 const OsPath home(envHome); 68 140 const OsPath xdgData = XDG_Path("XDG_DATA_HOME", home, home/".local/share/") / subdirectoryName; 69 141 const OsPath xdgConfig = XDG_Path("XDG_CONFIG_HOME", home, home/".config/" ) / subdirectoryName; 70 142 const OsPath xdgCache = XDG_Path("XDG_CACHE_HOME", home, home/".cache/" ) / subdirectoryName; 71 m_data = xdgData/""; 143 144 // We don't make the game vs. user data distinction on Unix 145 m_gameData = xdgData/""; 146 m_userData = m_gameData; 72 147 m_cache = xdgCache/""; 73 m_config = xdgConfig/"config"/""; 74 m_logs = xdgConfig/"logs"/""; 148 m_config = xdgConfig / "config"/""; 149 m_logs = xdgConfig / "logs"/""; 150 75 151 #endif 76 152 } 77 153 } … … 107 183 #endif 108 184 } 109 185 186 /*static*/ OsPath Paths::RootData(const OsPath& argv0) 187 { 110 188 189 #ifdef INSTALLED_DATADIR 190 return OsPath(STRINGIZE(INSTALLED_DATADIR))/""; 191 #else 192 193 # if OS_MACOSX 194 if (osx_IsAppBundleValid()) 195 { 196 debug_printf(L"Valid app bundle detected\n"); 197 198 std::string resourcesPath = osx_GetBundleResourcesPath(); 199 // Ensure we have a valid resources path 200 ENSURE(!resourcesPath.empty()); 201 202 return OsPath(resourcesPath)/"data"/""; 203 } 204 # endif // OS_MACOSX 205 206 return Root(argv0)/"data"/""; 207 208 #endif // INSTALLED_DATADIR 209 } 210 111 211 /*static*/ OsPath Paths::XDG_Path(const char* envname, const OsPath& home, const OsPath& defaultPath) 112 212 { 113 213 const char* path = getenv(envname); -
source/ps/GameSetup/Paths.h
1 /* Copyright (C) 20 09Wildfire Games.1 /* Copyright (C) 2012 Wildfire Games. 2 2 * This file is part of 0 A.D. 3 3 * 4 4 * 0 A.D. is free software: you can redistribute it and/or modify … … 21 21 #include "lib/os_path.h" 22 22 #include "CmdLineArgs.h" 23 23 24 /** 25 * Wrapper class for OS paths used by the game 26 */ 24 27 class Paths 25 28 { 26 29 public: 27 30 Paths(const CmdLineArgs& args); 28 31 32 /** 33 * Returns the game's root directory 34 */ 29 35 const OsPath& Root() const 30 36 { 31 37 return m_root; 32 38 } 33 39 40 /** 41 * Returns directory for read-only data installed with the game 42 */ 34 43 const OsPath& RData() const 35 44 { 36 45 return m_rdata; 37 46 } 38 47 39 const OsPath& Data() const 48 /** 49 * Returns directory for game-managed data and mods 50 */ 51 const OsPath& GameData() const 40 52 { 41 return m_ data;53 return m_gameData; 42 54 } 43 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 */ 44 69 const OsPath& Config() const 45 70 { 46 71 return m_config; 47 72 } 48 73 74 /** 75 * Returns cache directory 76 */ 49 77 const OsPath& Cache() const 50 78 { 51 79 return m_cache; 52 80 } 53 81 82 /** 83 * Returns logs directory 84 */ 54 85 const OsPath& Logs() const 55 86 { 56 87 return m_logs; … … 58 89 59 90 private: 60 91 static OsPath Root(const OsPath& argv0); 92 static OsPath RootData(const OsPath& argv0); 61 93 static OsPath XDG_Path(const char* envname, const OsPath& home, const OsPath& defaultPath); 62 94 63 95 // read-only directories, fixed paths relative to executable … … 65 97 OsPath m_rdata; 66 98 67 99 // writable directories 68 OsPath m_data; 100 OsPath m_gameData; 101 OsPath m_userData; 69 102 OsPath m_config; 70 103 OsPath m_cache; 71 104 OsPath m_logs; // special-cased in single-root-folder installations -
source/tools/dist/0ad.nsi
179 179 180 180 RMDir "$INSTDIR" 181 181 182 RMDir /r "$ APPDATA\0ad\cache"183 RMDir /r "$ APPDATA\0ad\logs"182 RMDir /r "$LOCALAPPDATA\0ad\cache" 183 RMDir /r "$LOCALAPPDATA\0ad\logs" 184 184 ; leave the other directories (screenshots, config files, etc) 185 185 186 186 !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder