Skip to content

Commit

Permalink
Fixed|Win32: Fixed native path issues
Browse files Browse the repository at this point in the history
The application binary path is a native path so it needs
native separators. Also, the plugins binary path needs to
be concatenated as a native path.
  • Loading branch information
skyjake committed Oct 23, 2012
1 parent 9dde956 commit 9769ebf
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
3 changes: 3 additions & 0 deletions doomsday/libdeng2/include/de/data/string.h
Expand Up @@ -113,6 +113,9 @@ class DENG2_PUBLIC String : public QString
/// Does a path concatenation on this string and the argument.
String operator / (const String& path) const;

/// Converts path separates to native separators.
String toNativePath() const;

/// Does a path concatenation on a native path. The directory separator
/// character depends on the platform.
String concatenateNativePath(const String& nativePath) const;
Expand Down
4 changes: 2 additions & 2 deletions doomsday/libdeng2/src/core/app.cpp
Expand Up @@ -41,7 +41,7 @@ App::App(int& argc, char** argv, GUIMode guiMode)
#endif
//_logBuffer.enable(Log::TRACE);

_appPath = applicationFilePath();
_appPath = String(applicationFilePath()).toNativePath();

LOG_INFO("Application path: ") << _appPath;

Expand All @@ -59,7 +59,7 @@ String App::nativeBinaryPath()
{
String path;
#ifdef WIN32
path = _appPath.fileNameNativePath() / "plugins";
path = _appPath.fileNameNativePath().concatenateNativePath("plugins");
#else
# ifdef MACOSX
path = _appPath.fileNameNativePath() / "../DengPlugins";
Expand Down
11 changes: 11 additions & 0 deletions doomsday/libdeng2/src/data/string.cpp
Expand Up @@ -85,6 +85,17 @@ String String::operator / (const String& path) const
return concatenatePath(path);
}

String String::toNativePath() const
{
String native = *this;
#ifdef WIN32
native.replace('/', '\\');
#else
native.replace('\\', '/');
#endif
return native;
}

String String::concatenatePath(const String& other, QChar dirChar) const
{
if(other.first() == dirChar)
Expand Down

0 comments on commit 9769ebf

Please sign in to comment.