From c89d1cf072f4ac34cfb35eadd8c9890b3de1b922 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Sat, 10 Mar 2012 15:56:24 +0200 Subject: Initial directory structure rework --- src/porting.cpp | 61 +++++++++++++++++++++++++-------------------------------- 1 file changed, 27 insertions(+), 34 deletions(-) (limited to 'src/porting.cpp') diff --git a/src/porting.cpp b/src/porting.cpp index 0adc955a9..edf950635 100644 --- a/src/porting.cpp +++ b/src/porting.cpp @@ -124,12 +124,12 @@ void signal_handler_init(void) Path mangler */ -std::string path_data = ".." DIR_DELIM "data"; -std::string path_userdata = ".."; +std::string path_share = ".." DIR_DELIM "share"; +std::string path_user = ".." DIR_DELIM "user"; std::string getDataPath(const char *subpath) { - return path_data + DIR_DELIM + subpath; + return path_share + DIR_DELIM + subpath; } void pathRemoveFile(char *path, char delim) @@ -163,16 +163,13 @@ void initializePaths() char buf[buflen]; DWORD len; - // Find path of executable and set path_data relative to it + // Find path of executable and set path_share relative to it len = GetModuleFileName(GetModuleHandle(NULL), buf, buflen); assert(len < buflen); pathRemoveFile(buf, '\\'); - // Use "./bin/../data" - path_data = std::string(buf) + DIR_DELIM ".." DIR_DELIM "data"; - - // Use "./bin/.." - path_userdata = std::string(buf) + DIR_DELIM ".."; + path_share = std::string(buf) + "\\..\\share"; + path_user = std::string(buf) + "\\..\\user"; /* Linux @@ -187,11 +184,8 @@ void initializePaths() pathRemoveFile(buf, '/'); - // Use "./bin/../data" - path_data = std::string(buf) + "/../data"; - - // Use "./bin/../" - path_userdata = std::string(buf) + "/.."; + path_share = std::string(buf) + "/../share"; + path_user = std::string(buf) + "/../user"; /* OS X @@ -201,8 +195,8 @@ void initializePaths() //TODO: Get path of executable. This assumes working directory is bin/ dstream<<"WARNING: Relative path not properly supported on OS X and FreeBSD" <" len = GetEnvironmentVariable("APPDATA", buf, buflen); assert(len < buflen); - path_userdata = std::string(buf) + DIR_DELIM + PROJECT_NAME; + path_user = std::string(buf) + DIR_DELIM + PROJECT_NAME; /* Linux @@ -251,15 +244,15 @@ void initializePaths() pathRemoveFile(buf, '/'); - path_data = std::string(buf) + "/../share/" + PROJECT_NAME; - //path_data = std::string(INSTALL_PREFIX) + "/share/" + PROJECT_NAME; - if (!fs::PathExists(path_data)) { - dstream<<"WARNING: data path " << path_data << " not found!"; - path_data = std::string(buf) + "/../data"; - dstream<<" Trying " << path_data << std::endl; + path_share = std::string(buf) + "/../share/" + PROJECT_NAME; + //path_share = std::string(INSTALL_PREFIX) + "/share/" + PROJECT_NAME; + if (!fs::PathExists(path_share)) { + dstream<<"WARNING: data path " << path_share << " not found!"; + path_share = std::string(buf) + "/../data"; + dstream<<" Trying " << path_share << std::endl; } - path_userdata = std::string(getenv("HOME")) + "/." + PROJECT_NAME; + path_user = std::string(getenv("HOME")) + "/." + PROJECT_NAME; /* OS X @@ -276,7 +269,7 @@ void initializePaths() { dstream<<"Bundle resource path: "<