Skip to content

Commit

Permalink
libdeng2|App: Check -userdir option for overriding runtime folder
Browse files Browse the repository at this point in the history
As with libdeng1, the -userdir option is used for overriding the
location where runtime files are written.

However, it is unnecessary and not recommended for most users to
override the runtime location.
  • Loading branch information
skyjake committed Oct 25, 2012
1 parent 126877e commit 470fda9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 11 deletions.
7 changes: 7 additions & 0 deletions doomsday/libdeng2/include/de/core/app.h
Expand Up @@ -95,6 +95,13 @@ namespace de
*/
String nativeBinaryPath();

/**
* Returns the native path where user-specific runtime files should be
* placed. The user can override the location using the @em -userdir
* command line option.
*/
String nativeHomePath();

/**
* Returns the application's file system.
*/
Expand Down
34 changes: 23 additions & 11 deletions doomsday/libdeng2/src/core/app.cpp
Expand Up @@ -72,6 +72,28 @@ String App::nativeBinaryPath()
return path;
}

String App::nativeHomePath()
{
int i;
if((i = _cmdLine.check("-userdir", 1)))
{
_cmdLine.makeAbsolutePath(i + 1);
return _cmdLine.at(i + 1);
}

#ifdef MACOSX
String nativeHome = QDesktopServices::storageLocation(QDesktopServices::HomeLocation);
nativeHome = nativeHome / "Library/Application Support/Doomsday Engine/runtime";
#elif WIN32
String nativeHome = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
nativeHome = nativeHome.concatenateNativePath("runtime");
#else // UNIX
String nativeHome = QDesktopServices::storageLocation(QDesktopServices::HomeLocation);
nativeHome = nativeHome / ".doomsday/runtime";
#endif
return nativeHome;
}

String App::nativeBasePath()
{
int i;
Expand Down Expand Up @@ -138,17 +160,7 @@ void App::initSubsystems(SubsystemInitFlags flags)
#endif

// User's home folder.
#ifdef MACOSX
String nativeHome = QDesktopServices::storageLocation(QDesktopServices::HomeLocation);
nativeHome = nativeHome / "Library/Application Support/Doomsday Engine/runtime";
#elif WIN32
String nativeHome = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
nativeHome = nativeHome.concatenateNativePath("runtime");
#else // UNIX
String nativeHome = QDesktopServices::storageLocation(QDesktopServices::HomeLocation);
nativeHome = nativeHome / ".doomsday/runtime";
#endif
_fs.makeFolder("/home").attach(new DirectoryFeed(nativeHome,
_fs.makeFolder("/home").attach(new DirectoryFeed(nativeHomePath(),
DirectoryFeed::AllowWrite | DirectoryFeed::CreateIfMissing));

// Populate the file system.
Expand Down

0 comments on commit 470fda9

Please sign in to comment.