Skip to content

Commit

Permalink
libdeng2|Unix: Use appropriate paths for de::FS
Browse files Browse the repository at this point in the history
The configured library and base paths are now inserted into the FS
using the appropriate feeds.

The logic for interpreting -basedir reflects the original in libdeng1.
  • Loading branch information
skyjake committed Jul 22, 2012
1 parent 012b941 commit 38ae884
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 8 deletions.
3 changes: 3 additions & 0 deletions doomsday/config_unix.pri
Expand Up @@ -49,6 +49,9 @@ contains(QMAKE_HOST.arch, x86_64) {
DENG_BASE_DIR = $$PREFIX/share/doomsday
DENG_DATA_DIR = $$DENG_BASE_DIR/data

DEFINES += DENG_BASE_DIR=\"\\\"$${DENG_BASE_DIR}/\\\"\"
DEFINES += DENG_LIBRARY_DIR=\"\\\"$${DENG_LIB_DIR}/\\\"\"

echo(Binary directory: $$DENG_BIN_DIR)
echo(Library directory: $$DENG_LIB_DIR)
echo(Doomsday base directory: $$DENG_BASE_DIR)
3 changes: 0 additions & 3 deletions doomsday/engine/engine.pro
Expand Up @@ -48,9 +48,6 @@ else:macx {
}
else {
# Generic Unix.
DEFINES += DENG_BASE_DIR=\"\\\"$${DENG_BASE_DIR}/\\\"\"
DEFINES += DENG_LIBRARY_DIR=\"\\\"$${DENG_LIB_DIR}/\\\"\"

QMAKE_LFLAGS += -rdynamic

!freebsd-*: LIBS += -ldl
Expand Down
52 changes: 47 additions & 5 deletions doomsday/libdeng2/src/core/app.cpp
Expand Up @@ -55,29 +55,71 @@ App::App(int& argc, char** argv, GUIMode guiMode)
#endif
}

void App::initSubsystems()
String App::nativeBinaryPath()
{
String appDir = _appPath.fileNameNativePath();
String path;
#ifdef WIN32
path = _appPath.fileNameNativePath();
#else
# ifdef MACOSX
path = "."; /// @todo Where are the plugins supposed to go?
# else
path = DENG_LIBRARY_DIR;
# endif
// Also check the system config files.
_unixInfo.path("libdir", path);
#endif
return path;
}

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

String path;
#ifdef WIN32
path = _appPath.fileNameNativePath().concatenateNativePath("..");
#else
# ifdef MACOSX
path = ".";
# else
path = DENG_BASE_DIR;
# endif
// Also check the system config files.
_unixInfo.path("basedir", path);
#endif
return path;
}

void App::initSubsystems()
{
// Initialize the built-in folders. This hooks up the default native
// directories into the appropriate places in the file system.
// All of these are in read-only mode.
#ifdef MACOSX
String appDir = _appPath.fileNameNativePath();
_fs.makeFolder("/bin").attach(new DirectoryFeed(appDir));
_fs.makeFolder("/data").attach(new DirectoryFeed(appDir / "../Resources"));
_fs.makeFolder("/config").attach(new DirectoryFeed(appDir / "../Resources/config"));
//fs_->makeFolder("/modules").attach(new DirectoryFeed("Resources/modules"));

#elif WIN32
String appDir = _appPath.fileNameNativePath();
_fs.makeFolder("/bin").attach(new DirectoryFeed(appDir.concatenateNativePath("..\\bin")));
_fs.makeFolder("/data").attach(new DirectoryFeed(appDir.concatenateNativePath("..\\data")));
_fs.makeFolder("/config").attach(new DirectoryFeed(appDir.concatenateNativePath("..\\data\\config")));
//fs_->makeFolder("/modules").attach(new DirectoryFeed("data\\modules"));

#else // UNIX
_fs.makeFolder("/bin").attach(new DirectoryFeed("bin"));
_fs.makeFolder("/data").attach(new DirectoryFeed("data"));
_fs.makeFolder("/config").attach(new DirectoryFeed("data/config"));
_fs.makeFolder("/bin").attach(new DirectoryFeed(nativeBinaryPath()));
String dataDir = nativeBasePath() / "data";
_fs.makeFolder("/data").attach(new DirectoryFeed(dataDir));
_fs.makeFolder("/config").attach(new DirectoryFeed(dataDir / "config"));
//fs_->makeFolder("/modules").attach(new DirectoryFeed("data/modules"));
#endif

Expand Down

0 comments on commit 38ae884

Please sign in to comment.