about summary refs log tree commit diff
path: root/src/libstd/path/windows.rs
diff options
context:
space:
mode:
authorKevin Ballard <kevin@sb.org>2014-01-17 23:07:53 -0800
committerKevin Ballard <kevin@sb.org>2014-01-17 23:07:53 -0800
commitb3c93b34f3fa81e9e2ade0cd05e0516faa7150ae (patch)
treeb5b73ff53ada67fd84ed055c3a7446a9a18f6361 /src/libstd/path/windows.rs
parentf4498c71e21308f6657d0150d5f473835e4b436f (diff)
downloadrust-b3c93b34f3fa81e9e2ade0cd05e0516faa7150ae.tar.gz
rust-b3c93b34f3fa81e9e2ade0cd05e0516faa7150ae.zip
Make WindowsPath::new("C:foo").root_path() return Some("C:")
Diffstat (limited to 'src/libstd/path/windows.rs')
-rw-r--r--src/libstd/path/windows.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/libstd/path/windows.rs b/src/libstd/path/windows.rs
index a42fdabef88..2d9d787d72d 100644
--- a/src/libstd/path/windows.rs
+++ b/src/libstd/path/windows.rs
@@ -432,9 +432,12 @@ impl GenericPath for Path {
     }
 
     fn root_path(&self) -> Option<Path> {
-        if self.is_absolute() {
+        if self.prefix.is_some() {
             Some(Path::new(match self.prefix {
-                Some(VerbatimDiskPrefix)|Some(DiskPrefix) => {
+                Some(DiskPrefix) if self.is_absolute() => {
+                    self.repr.slice_to(self.prefix_len()+1)
+                }
+                Some(VerbatimDiskPrefix) => {
                     self.repr.slice_to(self.prefix_len()+1)
                 }
                 _ => self.repr.slice_to(self.prefix_len())
@@ -1683,7 +1686,7 @@ mod tests {
     fn test_root_path() {
         assert_eq!(Path::new("a\\b\\c").root_path(), None);
         assert_eq!(Path::new("\\a\\b\\c").root_path(), Some(Path::new("\\")));
-        assert_eq!(Path::new("C:a").root_path(), None);
+        assert_eq!(Path::new("C:a").root_path(), Some(Path::new("C:")));
         assert_eq!(Path::new("C:\\a").root_path(), Some(Path::new("C:\\")));
         assert_eq!(Path::new("\\\\a\\b\\c").root_path(), Some(Path::new("\\\\a\\b")));
         assert_eq!(Path::new("\\\\?\\a\\b").root_path(), Some(Path::new("\\\\?\\a")));