Mercurial > projects > mde
comparison mde/setup/paths.d @ 75:25cb7420dc91
A massive overhaul/rewrite for the gui's data management and setup code. Currently much that was working is broken.
imde's classes are created in a static this instead of mde's main.
gl setup code moved from gl/basic.d to gl/draw.d
mergetag.DefaultData: now HIGH_LOW priority instead of LOW_HIGH. Reduced type list to only used types; small fix for indent function.
setup.paths: new NoFileException thrown instead of MTFileIOException
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Mon, 28 Jul 2008 18:17:48 +0100 |
parents | 3a737e06dc50 |
children | 79a1809421aa |
comparison
equal
deleted
inserted
replaced
74:cee261eba249 | 75:25cb7420dc91 |
---|---|
71 */ | 71 */ |
72 IReader makeMTReader (char[] file, PRIORITY readOrder, DataSet ds = null, bool rdHeader = false) | 72 IReader makeMTReader (char[] file, PRIORITY readOrder, DataSet ds = null, bool rdHeader = false) |
73 { | 73 { |
74 FilePath[] files = getFiles (file, readOrder); | 74 FilePath[] files = getFiles (file, readOrder); |
75 if (files is null) | 75 if (files is null) |
76 throw new MTFileIOException ("Unable to find the file: "~file~"[.mtt|mtb]"); | 76 throw new NoFileException ("Unable to find the file: "~file~"[.mtt|mtb]"); |
77 | 77 |
78 return new mdeReader (files, ds, rdHeader); | 78 return new mdeReader (files, ds, rdHeader); |
79 } | 79 } |
80 | 80 |
81 /** Creates an MT writer for file deciding on the best path to use. | 81 /** Creates an MT writer for file deciding on the best path to use. |
123 Cout ("\nLog file directory:\n\t")(logDir).newline; | 123 Cout ("\nLog file directory:\n\t")(logDir).newline; |
124 } | 124 } |
125 | 125 |
126 private: | 126 private: |
127 FilePath[] getFiles (char[] filename, PRIORITY readOrder) | 127 FilePath[] getFiles (char[] filename, PRIORITY readOrder) |
128 in { | 128 { |
129 assert (readOrder == PRIORITY.LOW_HIGH || | |
130 readOrder == PRIORITY.HIGH_LOW || | |
131 readOrder == PRIORITY.HIGH_ONLY ); | |
132 } body { | |
133 FilePath[] ret; | 129 FilePath[] ret; |
134 | 130 |
135 debug (mdeUnitTest) { | 131 debug (mdeUnitTest) { |
136 /* Alternate approach - just try from current directory. | 132 /* Alternate approach - just try from current directory. |
137 * Really just for unittests, but with the if condition it shouldn't break anything else. */ | 133 * Really just for unittests, but with the if condition it shouldn't break anything else. */ |
148 FilePath file = findFile (paths[i]~filename); | 144 FilePath file = findFile (paths[i]~filename); |
149 if (file !is null) | 145 if (file !is null) |
150 ret ~= file; | 146 ret ~= file; |
151 } | 147 } |
152 } else { | 148 } else { |
149 assert (readOrder == PRIORITY.HIGH_LOW || | |
150 readOrder == PRIORITY.HIGH_ONLY ); | |
151 | |
153 for (int i = pathsLen - 1; i >= 0; --i) { | 152 for (int i = pathsLen - 1; i >= 0; --i) { |
154 FilePath file = findFile (paths[i]~filename); | 153 FilePath file = findFile (paths[i]~filename); |
155 if (file !is null) { | 154 if (file !is null) { |
156 ret ~= file; | 155 ret ~= file; |
157 if (readOrder == PRIORITY.HIGH_ONLY) break; | 156 if (readOrder == PRIORITY.HIGH_ONLY) break; |
366 ubyte readersLen = 0; | 365 ubyte readersLen = 0; |
367 | 366 |
368 PRIORITY rdOrder; | 367 PRIORITY rdOrder; |
369 } | 368 } |
370 } | 369 } |
370 | |
371 /// Thrown when makeMTReader couldn't find a file. | |
372 class NoFileException : MTFileIOException { | |
373 this (char[] msg) { | |
374 super(msg); | |
375 } | |
376 } |