summaryrefslogtreecommitdiff
path: root/src/porting.cpp
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2012-03-25 23:10:09 +0300
committerPerttu Ahola <celeron55@gmail.com>2012-03-25 23:10:09 +0300
commit728d01ef4b8c7537232ac6c5d0b30efbbfff288d (patch)
treeee83020b45933b2344e73bf92daeb1a0ec6b3729 /src/porting.cpp
parent0557df8d065189db59dec1bca332d47471f1cd53 (diff)
downloadminetest-728d01ef4b8c7537232ac6c5d0b30efbbfff288d.tar.gz
minetest-728d01ef4b8c7537232ac6c5d0b30efbbfff288d.tar.bz2
minetest-728d01ef4b8c7537232ac6c5d0b30efbbfff288d.zip
MSVC build directory autodetection at startup
Diffstat (limited to 'src/porting.cpp')
-rw-r--r--src/porting.cpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/porting.cpp b/src/porting.cpp
index 522afa9ef..17d71a33e 100644
--- a/src/porting.cpp
+++ b/src/porting.cpp
@@ -28,6 +28,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "debug.h"
#include "filesys.h"
#include "log.h"
+#include "utility_string.h"
#ifdef __APPLE__
#include "CoreFoundation/CoreFoundation.h"
@@ -144,6 +145,13 @@ void pathRemoveFile(char *path, char delim)
path[i] = 0;
}
+bool detectMSVCBuildDir(char *c_path)
+{
+ std::string path(c_path);
+ const char *ends[] = {"bin\\Release", "bin\\Build", NULL};
+ return (removeStringEnd(path, ends) != "");
+}
+
void initializePaths()
{
#ifdef RUN_IN_PLACE
@@ -167,9 +175,16 @@ void initializePaths()
len = GetModuleFileName(GetModuleHandle(NULL), buf, buflen);
assert(len < buflen);
pathRemoveFile(buf, '\\');
-
- path_share = std::string(buf) + "\\..";
- path_user = std::string(buf) + "\\..";
+
+ if(detectMSVCBuildDir(buf)){
+ infostream<<"MSVC build directory detected"<<std::endl;
+ path_share = std::string(buf) + "\\..\\..";
+ path_user = std::string(buf) + "\\..\\..";
+ }
+ else{
+ path_share = std::string(buf) + "\\..";
+ path_user = std::string(buf) + "\\..";
+ }
/*
Linux