Skip to content

Commit 50ac893

Browse files
committed
Attempt to fix fs.dirname harder.
1 parent 9a1f097 commit 50ac893

File tree

3 files changed

+4
-7
lines changed

3 files changed

+4
-7
lines changed

src/lib/fs.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,9 @@ fn path_sep() -> str {
99
type path = str;
1010

1111
fn dirname(path p) -> path {
12-
auto sep = path_sep();
13-
assert (_str.byte_len(sep) == 1u);
14-
let int i = _str.rindex(p, sep.(0));
12+
let int i = _str.rindex(p, os_fs.path_sep as u8);
1513
if (i == -1) {
16-
// FIXME: the '/' character is a path separator on all 3 platforms we
17-
// support. This should probably be generalized a bit more in the
18-
// future, but for now this should work.
19-
i = _str.rindex(p, '/' as u8);
14+
i = _str.rindex(p, os_fs.alt_path_sep as u8);
2015
if (i == -1) {
2116
ret p;
2217
}

src/lib/posix_fs.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ fn list_dir(str path) -> vec[str] {
2020
}
2121

2222
const char path_sep = '/';
23+
const char alt_path_sep = '/';
2324

2425
// Local Variables:
2526
// mode: rust;

src/lib/win32_fs.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ fn list_dir(str path) -> vec[str] {
1414
* tag type.
1515
*/
1616
const char path_sep = '/';
17+
const char alt_path_sep = '\\';
1718

1819
// Local Variables:
1920
// mode: rust;

0 commit comments

Comments
 (0)