]> git.tdb.fi Git - libs/core.git/blobdiff - source/fs/dir.cpp
Change get_bin_dir logic to assume exe in cwd if not otherwise found
[libs/core.git] / source / fs / dir.cpp
index 2ae5122e63768492f54274a7b7062e861445a094..c0583cc5ca6fd9011065ed24d89e2d788e2cdcd8 100644 (file)
@@ -17,6 +17,15 @@ namespace FS {
 namespace
 {
 
+enum
+{
+#ifdef WIN32
+       ITEMSEP = ';'
+#else
+       ITEMSEP = ':'
+#endif
+};
+
 /** Helper function to determine the location of the program's executable.
 Caches the last result to cut down filesystem access with repeated calls. */
 const Path &get_bin_dir(const string &argv0)
@@ -30,7 +39,7 @@ const Path &get_bin_dir(const string &argv0)
                if(argv0.find('/')==string::npos)
                {
                        const char *path = getenv("PATH");
-                       vector<string> dirs = split(path, ':');
+                       vector<string> dirs = split(path, ITEMSEP);
                        for(vector<string>::const_iterator i=dirs.begin(); i!=dirs.end(); ++i)
                                if(exists(Path(*i)/argv0))
                                {
@@ -38,7 +47,8 @@ const Path &get_bin_dir(const string &argv0)
                                        break;
                                }
                }
-               else
+
+               if(exe.empty())
                        exe = realpath(argv0);
 
                last_argv0 = argv0;