about summary refs log tree commit diff
path: root/src/lib
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2011-10-05 12:01:10 -0700
committerBrian Anderson <banderson@mozilla.com>2011-10-05 16:21:55 -0700
commit82ef8519c3ce9c2bf1176a6319cccbb3a5376bd2 (patch)
tree52785c3fa386bbe797b314d333abfe5d619519ef /src/lib
parent8b4601e08eb0ac54f4c8c12b4dd762b89248abca (diff)
downloadrust-82ef8519c3ce9c2bf1176a6319cccbb3a5376bd2.tar.gz
rust-82ef8519c3ce9c2bf1176a6319cccbb3a5376bd2.zip
Fix some path handling in std::fs on win32
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/fs.rs11
-rw-r--r--src/lib/win32_fs.rs4
2 files changed, 14 insertions, 1 deletions
diff --git a/src/lib/fs.rs b/src/lib/fs.rs
index f9fcc67510e..ec389593f5b 100644
--- a/src/lib/fs.rs
+++ b/src/lib/fs.rs
@@ -144,6 +144,8 @@ fn normalize(p: path) -> path {
         ret t;
     }
 
+    #[cfg(target_os = "linux")]
+    #[cfg(target_os = "macos")]
     fn reabsolute(orig: path, new: path) -> path {
         if path_is_absolute(orig) {
             path_sep() + new
@@ -152,6 +154,15 @@ fn normalize(p: path) -> path {
         }
     }
 
+    #[cfg(target_os = "win32")]
+    fn reabsolute(orig: path, new: path) -> path {
+       if path_is_absolute(orig) && orig[0] == os_fs::path_sep as u8 {
+           str::from_char(os_fs::path_sep) + new
+       } else {
+           new
+       }
+    }
+
     fn reterminate(orig: path, new: path) -> path {
         let last = orig[str::byte_len(orig) - 1u];
         if last == os_fs::path_sep as u8
diff --git a/src/lib/win32_fs.rs b/src/lib/win32_fs.rs
index 06701249150..dcd8a905d2e 100644
--- a/src/lib/win32_fs.rs
+++ b/src/lib/win32_fs.rs
@@ -12,7 +12,9 @@ fn list_dir(path: str) -> [str] {
 
 fn path_is_absolute(p: str) -> bool {
     ret str::char_at(p, 0u) == '/' ||
-            str::char_at(p, 1u) == ':' && str::char_at(p, 2u) == '\\';
+            str::char_at(p, 1u) == ':'
+            && (str::char_at(p, 2u) == path_sep
+            || str::char_at(p, 2u) == alt_path_sep);
 }
 
 /* FIXME: win32 path handling actually accepts '/' or '\' and has subtly