diff options
| author | bors <bors@rust-lang.org> | 2014-01-19 15:31:57 -0800 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-01-19 15:31:57 -0800 |
| commit | f7cc8a625b4f405dfed8cd79dc9e59983eff3c9e (patch) | |
| tree | dddc37722f21b27e556132bd1b023735a4313e85 /src/libstd/path/windows.rs | |
| parent | 18061e85b79915deb9f04c78aac7b63b837432dd (diff) | |
| parent | b3c93b34f3fa81e9e2ade0cd05e0516faa7150ae (diff) | |
| download | rust-f7cc8a625b4f405dfed8cd79dc9e59983eff3c9e.tar.gz rust-f7cc8a625b4f405dfed8cd79dc9e59983eff3c9e.zip | |
auto merge of #11643 : kballard/rust/path-root-path, r=erickt
Diffstat (limited to 'src/libstd/path/windows.rs')
| -rw-r--r-- | src/libstd/path/windows.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/libstd/path/windows.rs b/src/libstd/path/windows.rs index 86a9d2235d0..0e5b7894e74 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()) @@ -1688,7 +1691,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"))); |
