 |
Changeset 3849
- Timestamp:
- 08/03/08 17:48:34
(4 months ago)
- Author:
- kris
- Message:
more fixes related to #1210
Now have to convert paths on each call to set(), given const issues. This sucks
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r3843 |
r3849 |
|
| 114 | 114 | this (char[] filepath = null) |
|---|
| 115 | 115 | { |
|---|
| 116 | | set (filepath); |
|---|
| | 116 | set (filepath, true); |
|---|
| 117 | 117 | } |
|---|
| 118 | 118 | |
|---|
| … | … | |
| 428 | 428 | FilePath set (FilePath path) |
|---|
| 429 | 429 | { |
|---|
| 430 | | return set (path.toString); |
|---|
| 431 | | } |
|---|
| 432 | | |
|---|
| 433 | | /*********************************************************************** |
|---|
| 434 | | |
|---|
| 435 | | Reset the content of this path, and reparse. |
|---|
| 436 | | |
|---|
| 437 | | ***********************************************************************/ |
|---|
| 438 | | |
|---|
| 439 | | final FilePath set (char[] path) |
|---|
| | 430 | return set (path.toString, false); |
|---|
| | 431 | } |
|---|
| | 432 | |
|---|
| | 433 | /*********************************************************************** |
|---|
| | 434 | |
|---|
| | 435 | Reset the content of this path, and reparse. There's an |
|---|
| | 436 | optional boolean flag to convert the path into standard |
|---|
| | 437 | form, before parsing (converting '\' into '/') |
|---|
| | 438 | |
|---|
| | 439 | ***********************************************************************/ |
|---|
| | 440 | |
|---|
| | 441 | final FilePath set (char[] path, bool convert = false) |
|---|
| 440 | 442 | { |
|---|
| 441 | 443 | p.end_ = path.length; |
|---|
| … | … | |
| 443 | 445 | expand (p.end_); |
|---|
| 444 | 446 | if (p.end_) |
|---|
| 445 | | p.fp[0 .. p.end_] = path; |
|---|
| | 447 | { |
|---|
| | 448 | p.fp[0 .. p.end_] = path; |
|---|
| | 449 | if (convert) |
|---|
| | 450 | .standard (p.fp [0 .. p.end_]); |
|---|
| | 451 | } |
|---|
| 446 | 452 | |
|---|
| 447 | 453 | p.fp[p.end_] = '\0'; |
|---|
| … | … | |
| 620 | 626 | private final FilePath parse () |
|---|
| 621 | 627 | { |
|---|
| 622 | | p.parse (p.fp, p.end_, true); |
|---|
| | 628 | p.parse (p.fp, p.end_); |
|---|
| 623 | 629 | return this; |
|---|
| 624 | 630 | } |
|---|
| … | … | |
| 921 | 927 | { |
|---|
| 922 | 928 | FS.rename (cString, dst~'\0'); |
|---|
| 923 | | return this.set (dst); |
|---|
| | 929 | return this.set (dst, true); |
|---|
| 924 | 930 | } |
|---|
| 925 | 931 | |
|---|
| r3843 |
r3849 |
|
| 160 | 160 | static void exception (char[] filename) |
|---|
| 161 | 161 | { |
|---|
| 162 | | throw new IOException (filename[0..$-1] ~ ": " ~ SysError.lastMsg); |
|---|
| | 162 | exception (filename[0..$-1] ~ ": ", SysError.lastMsg); |
|---|
| | 163 | } |
|---|
| | 164 | |
|---|
| | 165 | /*********************************************************************** |
|---|
| | 166 | |
|---|
| | 167 | Throw an IO exception |
|---|
| | 168 | |
|---|
| | 169 | ***********************************************************************/ |
|---|
| | 170 | |
|---|
| | 171 | static void exception (char[] prefix, char[] error) |
|---|
| | 172 | { |
|---|
| | 173 | throw new IOException (prefix ~ error); |
|---|
| 163 | 174 | } |
|---|
| 164 | 175 | |
|---|
| … | … | |
| 934 | 945 | PathParser parse (char[] path) |
|---|
| 935 | 946 | { |
|---|
| 936 | | return parse (path, path.length, false); |
|---|
| | 947 | return parse (path, path.length); |
|---|
| 937 | 948 | } |
|---|
| 938 | 949 | |
|---|
| … | … | |
| 1142 | 1153 | ***********************************************************************/ |
|---|
| 1143 | 1154 | |
|---|
| 1144 | | package PathParser parse (char[] path, uint end, bool mutate) |
|---|
| | 1155 | package PathParser parse (char[] path, uint end) |
|---|
| 1145 | 1156 | { |
|---|
| 1146 | 1157 | end_ = end; |
|---|
| … | … | |
| 1158 | 1169 | break; |
|---|
| 1159 | 1170 | |
|---|
| 1160 | | case '\\': |
|---|
| 1161 | | if (mutate is false) |
|---|
| 1162 | | throw new IOException ("unexpected '\\' character in path: "~path); |
|---|
| 1163 | | else |
|---|
| 1164 | | fp[i] = '/'; |
|---|
| 1165 | | // fall through! |
|---|
| 1166 | | |
|---|
| 1167 | 1171 | case FileConst.PathSeparatorChar: |
|---|
| 1168 | 1172 | if (name_ < 0) |
|---|
| 1169 | 1173 | name_ = i + 1; |
|---|
| 1170 | 1174 | break; |
|---|
| | 1175 | |
|---|
| | 1176 | // Windows file separators are illegal. Use |
|---|
| | 1177 | // standard() or equivalent to convert first |
|---|
| | 1178 | case '\\': |
|---|
| | 1179 | FS.exception ("unexpected '\\' character in path: ", path); |
|---|
| 1171 | 1180 | |
|---|
| 1172 | 1181 | version (Win32) |
|---|
Download in other formats:
|
 |
 |
|
 |
Copyright © 2006-2008 Tango. All Rights Reserved. | Page Width:
Static or
Dynamic