Change back the ldc.conf search path and add ~/.ldc

New one:
cwd, ~/.ldc, prefix/etc, prefix/etc/ldc, /etc, /etc/ldc, next-to-binary
This commit is contained in:
Christian Kamm
2009-07-13 22:56:59 +02:00
parent 919f8d6bfa
commit eb3cd8872e

View File

@@ -26,37 +26,46 @@ ConfigFile::~ConfigFile()
bool ConfigFile::locate(sys::Path& p, const char* argv0, void* mainAddr, const char* filename) bool ConfigFile::locate(sys::Path& p, const char* argv0, void* mainAddr, const char* filename)
{ {
// temporary configuration
// try the current working dir // try the current working dir
p = sys::Path::GetCurrentDirectory(); p = sys::Path::GetCurrentDirectory();
p.appendComponent(filename); p.appendComponent(filename);
if (p.exists()) if (p.exists())
return true; return true;
// try next to the executable // user configuration
p = sys::Path::GetMainExecutable(argv0, mainAddr);
p.eraseComponent(); // try ~/.ldc
p = sys::Path::GetUserHomeDirectory();
p.appendComponent(".ldc");
p.appendComponent(filename); p.appendComponent(filename);
if (p.exists()) if (p.exists())
return true; return true;
// try the user home dir #if _WIN32
// try home dir
p = sys::Path::GetUserHomeDirectory(); p = sys::Path::GetUserHomeDirectory();
p.appendComponent(filename); p.appendComponent(filename);
if (p.exists()) if (p.exists())
return true; return true;
// try the install-prefix/etc
p = sys::Path(LDC_INSTALL_PREFIX);
#if !_WIN32
// Does Windows need something similar?
p.appendComponent("etc");
#endif #endif
// system configuration
#if _WIN32
// try the install-prefix
p = sys::Path(LDC_INSTALL_PREFIX);
p.appendComponent(filename);
if (p.exists())
return true;
#else
// try the install-prefix/etc
p = sys::Path(LDC_INSTALL_PREFIX);
p.appendComponent("etc");
p.appendComponent(filename); p.appendComponent(filename);
if (p.exists()) if (p.exists())
return true; return true;
#if !_WIN32
// Does Windows need something similar to these?
// try the install-prefix/etc/ldc // try the install-prefix/etc/ldc
p = sys::Path(LDC_INSTALL_PREFIX); p = sys::Path(LDC_INSTALL_PREFIX);
@@ -79,6 +88,13 @@ bool ConfigFile::locate(sys::Path& p, const char* argv0, void* mainAddr, const c
return true; return true;
#endif #endif
// try next to the executable
p = sys::Path::GetMainExecutable(argv0, mainAddr);
p.eraseComponent();
p.appendComponent(filename);
if (p.exists())
return true;
return false; return false;
} }