Fix --color command line parameter ignorance (#7173)
[oweals/minetest.git] / src / porting.cpp
index 302e6989a1ca075caad8e858f241340e9ef60cb1..76fd592d6083d81c171a3496156ac40df5535402 100644 (file)
@@ -380,20 +380,27 @@ bool setSystemPaths()
                "Failed to get current executable path");
        pathRemoveFile(buf, '\\');
 
+       std::string exepath(buf);
+
        // Use ".\bin\.."
-       path_share = std::string(buf) + "\\..";
+       path_share = exepath + "\\..";
+       if (detectMSVCBuildDir(exepath)) {
+               // The msvc build dir schould normaly not be present if properly installed,
+               // but its usefull for debugging.
+               path_share += DIR_DELIM "..";
+       }
 
-       // Use "C:\Documents and Settings\user\Application Data\<PROJECT_NAME>"
+       // Use "C:\Users\<user>\AppData\Roaming\<PROJECT_NAME_C>"
        DWORD len = GetEnvironmentVariable("APPDATA", buf, sizeof(buf));
        FATAL_ERROR_IF(len == 0 || len > sizeof(buf), "Failed to get APPDATA");
 
-       path_user = std::string(buf) + DIR_DELIM + PROJECT_NAME;
+       path_user = std::string(buf) + DIR_DELIM + PROJECT_NAME_C;
        return true;
 }
 
 
 //// Linux
-#elif defined(__linux__)
+#elif defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
 
 bool setSystemPaths()
 {
@@ -561,6 +568,10 @@ void initializePaths()
        if (!setSystemPaths())
                errorstream << "Failed to get one or more system-wide path" << std::endl;
 
+
+#  ifdef _WIN32
+       path_cache = path_user + DIR_DELIM + "cache";
+#  else
        // Initialize path_cache
        // First try $XDG_CACHE_HOME/PROJECT_NAME
        const char *cache_dir = getenv("XDG_CACHE_HOME");
@@ -577,7 +588,8 @@ void initializePaths()
        }
        // Migrate cache folder to new location if possible
        migrateCachePath();
-#endif
+#  endif // _WIN32
+#endif // RUN_IN_PLACE
 
        infostream << "Detected share path: " << path_share << std::endl;
        infostream << "Detected user path: " << path_user << std::endl;