From: Perttu Ahola Date: Sun, 25 Mar 2012 20:10:09 +0000 (+0300) Subject: MSVC build directory autodetection at startup X-Git-Url: http://81.2.79.47:8989/gitweb/?a=commitdiff_plain;h=728d01ef4b8c7537232ac6c5d0b30efbbfff288d;p=zefram%2Fminetest%2Fminetest_engine.git MSVC build directory autodetection at startup --- diff --git a/src/porting.cpp b/src/porting.cpp index 522afa9e..17d71a33 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"<