Mercurial > projects > mde
diff mde/setup/paths.d @ 67:108d123238c0
Changes to work with tango r3700 (post 0.99.6).
Changes to logging.
Replaced many uses of PathView with FilePath.
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Thu, 03 Jul 2008 12:40:31 +0100 |
parents | 66d555da083e |
children | 3a737e06dc50 |
line wrap: on
line diff
--- a/mde/setup/paths.d Sun Jun 29 15:40:37 2008 +0100 +++ b/mde/setup/paths.d Thu Jul 03 12:40:31 2008 +0100 @@ -26,7 +26,7 @@ * Currently the paths are found as follows: (see codeDoc/paths.txt) */ /* Implementation note: -* All paths are stored internally as strings, rather than as an instance of FilePath/PathView once +* All paths are stored internally as strings, rather than as an instance of FilePath/FilePath once * the FilePath has served its immediate purpose, since it's more convenient and creating new * FilePaths for adjusted paths should be no slower than mutating existing ones. */ module mde.setup.paths; @@ -71,7 +71,7 @@ */ IReader makeMTReader (char[] file, PRIORITY readOrder, DataSet ds = null, bool rdHeader = false) { - PathView[] files = getFiles (file, readOrder); + FilePath[] files = getFiles (file, readOrder); if (files is null) throw new MTFileIOException ("Unable to find the file: "~file~"[.mtt|mtb]"); @@ -95,7 +95,7 @@ * matches are found), or "no file found". Intended for user output only. */ char[] getFileName (char[] file, PRIORITY readOrder) { - PathView[] files = getFiles (file, readOrder); + FilePath[] files = getFiles (file, readOrder); if (files is null) return "no file found"; @@ -124,22 +124,22 @@ } private: - PathView[] getFiles (char[] filename, PRIORITY readOrder) + FilePath[] getFiles (char[] filename, PRIORITY readOrder) in { assert (readOrder == PRIORITY.LOW_HIGH || readOrder == PRIORITY.HIGH_LOW || readOrder == PRIORITY.HIGH_ONLY ); } body { - PathView[] ret; + FilePath[] ret; if (readOrder == PRIORITY.LOW_HIGH) { for (size_t i = 0; i < pathsLen; ++i) { - PathView file = findFile (paths[i]~filename); + FilePath file = findFile (paths[i]~filename); if (file !is null) ret ~= file; } } else { for (int i = pathsLen - 1; i >= 0; --i) { - PathView file = findFile (paths[i]~filename); + FilePath file = findFile (paths[i]~filename); if (file !is null) { ret ~= file; if (readOrder == PRIORITY.HIGH_ONLY) break; @@ -208,10 +208,10 @@ // Base paths: // Static data (must exist): - PathView staticPath = + FilePath staticPath = findPath (false, "/usr/share/games/mde", "/usr/local/share/games/mde", "data"); // Config (can just use defaults if necessary, so long as we can save afterwards): - PathView userPath = findPath (true, HOME~"/.config/mde", HOME~"/.mde"); + FilePath userPath = findPath (true, HOME~"/.config/mde", HOME~"/.mde"); // Static data paths: dataDir.addPath (staticPath.toString); // we know this is valid anyway @@ -236,9 +236,9 @@ //http://www.dsource.org/projects/tango/forums/topic/187 // Base paths: - PathView installPath = findPath (false, base); - PathView staticPath = findPath (false, installPath.append("data").toString); - PathView userPath = findPath (true, installPath.append("user").toString); // FIXME: see above + FilePath installPath = findPath (false, base); + FilePath staticPath = findPath (false, installPath.append("data").toString); + FilePath userPath = findPath (true, installPath.append("user").toString); // FIXME: see above // Static data paths: dataDir.addPath (staticPath.toString); // we know this is valid anyway @@ -277,7 +277,7 @@ /* Try each path in succession, returning the first to exist and be a folder. * If none are valid and create is true, will try creating each in turn. * If still none are valid, throws. */ - PathView findPath (bool create, char[][] paths ...) { + FilePath findPath (bool create, char[][] paths ...) { FilePath[] fps; fps.length = paths.length; foreach (i,path; paths) { @@ -305,7 +305,7 @@ */ class mdeReader : IReader { - private this (PathView[] files, DataSet ds, bool rdHeader) + private this (FilePath[] files, DataSet ds, bool rdHeader) in { assert (files !is null, "mdeReader.this: files is null"); } body {