changeset 1536:49ae9728bea4

Check for ldc.conf next to the ldc binary before home and etc. The new search order is * current working directory * next to executable * user home directory * prefix/etc * prefix/etc/ldc * /etc * /etc/ldc
author Christian Kamm <kamm incasoftware de>
date Mon, 13 Jul 2009 22:24:12 +0200
parents 61f12f4651b5
children ee6b20e7aedb
files gen/configfile.cpp
diffstat 1 files changed, 13 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/gen/configfile.cpp	Mon Jul 13 20:16:15 2009 +0200
+++ b/gen/configfile.cpp	Mon Jul 13 22:24:12 2009 +0200
@@ -26,19 +26,26 @@
 
 bool ConfigFile::locate(sys::Path& p, const char* argv0, void* mainAddr, const char* filename)
 {
-    // 1) try the current working dir
+    // try the current working dir
     p = sys::Path::GetCurrentDirectory();
     p.appendComponent(filename);
     if (p.exists())
         return true;
 
-    // 2) try the user home dir
+    // try next to the executable
+    p = sys::Path::GetMainExecutable(argv0, mainAddr);
+    p.eraseComponent();
+    p.appendComponent(filename);
+    if (p.exists())
+        return true;
+        
+    // try the user home dir
     p = sys::Path::GetUserHomeDirectory();
     p.appendComponent(filename);
     if (p.exists())
         return true;
         
-    // 3) try the install-prefix/etc
+    // try the install-prefix/etc
     p = sys::Path(LDC_INSTALL_PREFIX);
 #if !_WIN32
     // Does Windows need something similar?
@@ -51,7 +58,7 @@
 #if !_WIN32
     // Does Windows need something similar to these?
 
-    // 4) try the install-prefix/etc/ldc
+    // try the install-prefix/etc/ldc
     p = sys::Path(LDC_INSTALL_PREFIX);
     p.appendComponent("etc");
     p.appendComponent("ldc");
@@ -59,26 +66,19 @@
     if (p.exists())
         return true;
 
-    // 5) try /etc (absolute path)
+    // try /etc (absolute path)
     p = sys::Path("/etc");
     p.appendComponent(filename);
     if (p.exists())
         return true;
 
-    // 6) try /etc/ldc (absolute path)
+    // try /etc/ldc (absolute path)
     p = sys::Path("/etc/ldc");
     p.appendComponent(filename);
     if (p.exists())
         return true;
 #endif
 
-    // 7) try next to the executable
-    p = sys::Path::GetMainExecutable(argv0, mainAddr);
-    p.eraseComponent();
-    p.appendComponent(filename);
-    if (p.exists())
-        return true;
-        
     return false;
 }