comparison mde/file/paths.d @ 151:e785e98d3b78

Updated for compatibility with tango 0.99.8.
author Diggory Hardy <diggory.hardy@gmail.com>
date Sat, 04 Apr 2009 17:32:18 +0200
parents 9f035cd139c6
children
comparison
equal deleted inserted replaced
150:42fb97d9ff9e 151:e785e98d3b78
49 import tango.util.container.SortedMap; 49 import tango.util.container.SortedMap;
50 import tango.sys.Environment; 50 import tango.sys.Environment;
51 } else version (Windows) 51 } else version (Windows)
52 import tango.sys.win32.SpecialPath; 52 import tango.sys.win32.SpecialPath;
53 53
54 debug { 54 import tango.util.log.Log : Log, Logger;
55 import tango.util.log.Log : Log, Logger; 55 private Logger logger;
56 private Logger logger; 56 static this() {
57 static this() { 57 logger = Log.getLogger ("mde.file.paths");
58 logger = Log.getLogger ("mde.file.paths");
59 }
60 } 58 }
61 59
62 /** Order to read files in. 60 /** Order to read files in.
63 * 61 *
64 * Values: HIGH_LOW, LOW_HIGH, HIGH_ONLY. */ 62 * Values: HIGH_LOW, LOW_HIGH, HIGH_ONLY. */
195 try { 193 try {
196 fp.create; 194 fp.create;
197 paths[pathsLen++] = fp.toString~'/'; 195 paths[pathsLen++] = fp.toString~'/';
198 return true; 196 return true;
199 } catch (Exception e) { 197 } catch (Exception e) {
200 // No logging avaiable yet: Use Stdout/Cout 198 logger.error ("Creating path {} failed:" ~ e.msg, path);
201 Cout ("Creating path "~path~" failed:" ~ e.msg).newline;
202 } 199 }
203 } 200 }
204 return false; 201 return false;
205 } 202 }
206 203
207 void coutPaths () { 204 void coutPaths () {
208 if (pathsLen) { 205 if (pathsLen) {
209 for (size_t i = 0; i < pathsLen; ++i) 206 for (size_t i = 0; i < pathsLen; ++i)
210 Cout ("\n\t" ~ paths[i]); 207 Cout ("\n\t" ~ paths[i]);
211 } else 208 } else
212 Cout ("[none]"); 209 Cout (" [none]");
213 } 210 }
214 211
215 // Use a static array to store all possible paths with separate length counters. 212 // Use a static array to store all possible paths with separate length counters.
216 // Lowest priority paths are first. 213 // Lowest priority paths are first.
217 char[][MAX_PATHS] paths; 214 char[][MAX_PATHS] paths;
308 305
309 // Configuration paths: 306 // Configuration paths:
310 confDir.tryPath (userPath.toString ~ "/conf", true); 307 confDir.tryPath (userPath.toString ~ "/conf", true);
311 if (extraConfPath) confDir.tryPath (extraConfPath); 308 if (extraConfPath) confDir.tryPath (extraConfPath);
312 309
313 if (!dataDir.pathsLen) throw new mdeException ("Fatal: no data path found!"); 310 if (dataDir.pathsLen==0) throw new mdeException ("Fatal: no data path found!");
314 if (!confDir.pathsLen) throw new mdeException ("Fatal: no conf path found!"); 311 if (confDir.pathsLen==0) throw new mdeException ("Fatal: no conf path found!");
315 312
316 for (int i = dataDir.pathsLen - 1; i >= 0; --i) { 313 for (int i = dataDir.pathsLen - 1; i >= 0; --i) {
317 FilePath font = FilePath (dataDir.paths[i] ~ "fonts"); 314 FilePath font = FilePath (dataDir.paths[i] ~ "fonts");
318 Cout ("considering: ")(font.toString).newline;
319 if (font.exists && font.isFolder) 315 if (font.exists && font.isFolder)
320 fontPaths[iFP++] = font; 316 fontPaths[iFP++] = font;
321 } 317 }
322 fontPaths.length = iFP; 318 fontPaths.length = iFP;
323 319