Attempt to fix fs.dirname harder.

This commit is contained in:
Graydon Hoare 2011-05-05 14:31:10 -07:00
parent 9a1f0977a2
commit 50ac893b00
3 changed files with 4 additions and 7 deletions

View File

@ -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;
}

View File

@ -20,6 +20,7 @@ fn list_dir(str path) -> vec[str] {
}
const char path_sep = '/';
const char alt_path_sep = '/';
// Local Variables:
// mode: rust;

View File

@ -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;