Mercurial > projects > ldc
comparison gen/configfile.cpp @ 1537:ee6b20e7aedb
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
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Mon, 13 Jul 2009 22:56:59 +0200 |
parents | 49ae9728bea4 |
children | 40bd4a0d4870 |
comparison
equal
deleted
inserted
replaced
1536:49ae9728bea4 | 1537:ee6b20e7aedb |
---|---|
24 } | 24 } |
25 | 25 |
26 | 26 |
27 bool ConfigFile::locate(sys::Path& p, const char* argv0, void* mainAddr, const char* filename) | 27 bool ConfigFile::locate(sys::Path& p, const char* argv0, void* mainAddr, const char* filename) |
28 { | 28 { |
29 // temporary configuration | |
30 | |
29 // try the current working dir | 31 // try the current working dir |
30 p = sys::Path::GetCurrentDirectory(); | 32 p = sys::Path::GetCurrentDirectory(); |
31 p.appendComponent(filename); | 33 p.appendComponent(filename); |
32 if (p.exists()) | 34 if (p.exists()) |
33 return true; | 35 return true; |
34 | 36 |
35 // try next to the executable | 37 // user configuration |
36 p = sys::Path::GetMainExecutable(argv0, mainAddr); | 38 |
37 p.eraseComponent(); | 39 // try ~/.ldc |
40 p = sys::Path::GetUserHomeDirectory(); | |
41 p.appendComponent(".ldc"); | |
38 p.appendComponent(filename); | 42 p.appendComponent(filename); |
39 if (p.exists()) | 43 if (p.exists()) |
40 return true; | 44 return true; |
41 | 45 |
42 // try the user home dir | 46 #if _WIN32 |
47 // try home dir | |
43 p = sys::Path::GetUserHomeDirectory(); | 48 p = sys::Path::GetUserHomeDirectory(); |
44 p.appendComponent(filename); | 49 p.appendComponent(filename); |
45 if (p.exists()) | 50 if (p.exists()) |
46 return true; | 51 return true; |
47 | 52 #endif |
48 // try the install-prefix/etc | 53 |
54 // system configuration | |
55 | |
56 #if _WIN32 | |
57 // try the install-prefix | |
49 p = sys::Path(LDC_INSTALL_PREFIX); | 58 p = sys::Path(LDC_INSTALL_PREFIX); |
50 #if !_WIN32 | |
51 // Does Windows need something similar? | |
52 p.appendComponent("etc"); | |
53 #endif | |
54 p.appendComponent(filename); | 59 p.appendComponent(filename); |
55 if (p.exists()) | 60 if (p.exists()) |
56 return true; | 61 return true; |
57 | 62 #else |
58 #if !_WIN32 | 63 // try the install-prefix/etc |
59 // Does Windows need something similar to these? | 64 p = sys::Path(LDC_INSTALL_PREFIX); |
65 p.appendComponent("etc"); | |
66 p.appendComponent(filename); | |
67 if (p.exists()) | |
68 return true; | |
60 | 69 |
61 // try the install-prefix/etc/ldc | 70 // try the install-prefix/etc/ldc |
62 p = sys::Path(LDC_INSTALL_PREFIX); | 71 p = sys::Path(LDC_INSTALL_PREFIX); |
63 p.appendComponent("etc"); | 72 p.appendComponent("etc"); |
64 p.appendComponent("ldc"); | 73 p.appendComponent("ldc"); |
77 p.appendComponent(filename); | 86 p.appendComponent(filename); |
78 if (p.exists()) | 87 if (p.exists()) |
79 return true; | 88 return true; |
80 #endif | 89 #endif |
81 | 90 |
91 // try next to the executable | |
92 p = sys::Path::GetMainExecutable(argv0, mainAddr); | |
93 p.eraseComponent(); | |
94 p.appendComponent(filename); | |
95 if (p.exists()) | |
96 return true; | |
97 | |
82 return false; | 98 return false; |
83 } | 99 } |
84 | 100 |
85 bool ConfigFile::read(const char* argv0, void* mainAddr, const char* filename) | 101 bool ConfigFile::read(const char* argv0, void* mainAddr, const char* filename) |
86 { | 102 { |