From 50ac893b00853fa832a0f689b81104bd82e2a9b5 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Thu, 5 May 2011 14:31:10 -0700 Subject: Attempt to fix fs.dirname harder. --- src/lib/fs.rs | 9 ++------- src/lib/posix_fs.rs | 1 + src/lib/win32_fs.rs | 1 + 3 files changed, 4 insertions(+), 7 deletions(-) (limited to 'src/lib') diff --git a/src/lib/fs.rs b/src/lib/fs.rs index 29719233..0a951e5a 100644 --- a/src/lib/fs.rs +++ b/src/lib/fs.rs @@ -9,14 +9,9 @@ fn path_sep() -> str { type path = str; fn dirname(path p) -> path { - auto sep = path_sep(); - assert (_str.byte_len(sep) == 1u); - let int i = _str.rindex(p, sep.(0)); + let int i = _str.rindex(p, os_fs.path_sep as u8); if (i == -1) { - // FIXME: the '/' character is a path separator on all 3 platforms we - // support. This should probably be generalized a bit more in the - // future, but for now this should work. - i = _str.rindex(p, '/' as u8); + i = _str.rindex(p, os_fs.alt_path_sep as u8); if (i == -1) { ret p; } diff --git a/src/lib/posix_fs.rs b/src/lib/posix_fs.rs index f4cf12d3..99f411e7 100644 --- a/src/lib/posix_fs.rs +++ b/src/lib/posix_fs.rs @@ -20,6 +20,7 @@ fn list_dir(str path) -> vec[str] { } const char path_sep = '/'; +const char alt_path_sep = '/'; // Local Variables: // mode: rust; diff --git a/src/lib/win32_fs.rs b/src/lib/win32_fs.rs index 2d0ea38c..94599e3c 100644 --- a/src/lib/win32_fs.rs +++ b/src/lib/win32_fs.rs @@ -14,6 +14,7 @@ fn list_dir(str path) -> vec[str] { * tag type. */ const char path_sep = '/'; +const char alt_path_sep = '\\'; // Local Variables: // mode: rust; -- cgit v1.2.3