# HG changeset patch # User Kelly Wilson # Date 1244162167 21600 # Node ID df0ffca8a6362dc07b680ccaa7504c133e4e5ccc # Parent 1f29cbc36bf5c9d12af26b5f51d5eca124e45a09 There was another fix needed here for reading %%ldcbinarypath%% diff -r 1f29cbc36bf5 -r df0ffca8a636 gen/configfile.cpp --- a/gen/configfile.cpp Thu Jun 04 16:46:05 2009 -0600 +++ b/gen/configfile.cpp Thu Jun 04 18:36:07 2009 -0600 @@ -28,9 +28,24 @@ delete cfg; } +#if _WIN32 +sys::Path ConfigGetExePath(sys::Path p) +{ + char buf[MAX_PATH]; + GetModuleFileName(NULL, buf, MAX_PATH); + p = buf; + p.eraseComponent(); + return p; +} +#endif + + bool ConfigFile::read(const char* argv0, void* mainAddr, const char* filename) { +#if _WIN32 + std::string exeDirectoryName; +#endif // try to find the config file // 1) try the current working dir @@ -56,14 +71,13 @@ if (!p.exists()) { #if _WIN32 - char buf[256]; - GetModuleFileName(NULL, buf, 256); - p = buf; + p = ConfigGetExePath(p); + exeDirectoryName = p.toString(); #else // 4) try next to the executable p = sys::Path::GetMainExecutable(argv0, mainAddr); + p.eraseComponent(); #endif - p.eraseComponent(); p.appendComponent(filename); if (!p.exists()) { @@ -97,7 +111,22 @@ if (root.exists("switches")) { std::string binpathkey = "%%ldcbinarypath%%"; + + #if _WIN32 + std::string binpath; + //This will happen if ldc.conf is found somewhere other than + //beside the ldc executable + if (exeDirectoryName == "") + { + sys::Path p; + p = ConfigGetExePath(p); + exeDirectoryName = p.toString(); + } + binpath = exeDirectoryName; + #else std::string binpath = sys::Path::GetMainExecutable(argv0, mainAddr).getDirname(); + #endif + libconfig::Setting& arr = cfg->lookup("default.switches"); int len = arr.getLength();