diff options
| author | Ian Douglas Scott <ian@iandouglasscott.com> | 2017-08-18 12:04:45 -0700 |
|---|---|---|
| committer | Ian Douglas Scott <ian@iandouglasscott.com> | 2017-08-18 12:04:45 -0700 |
| commit | b272f6ca05e9210dbe6c605a301d5a16007f322f (patch) | |
| tree | 4f9fa4906dae3911496a9000de02733e3426d4a8 /src/libstd | |
| parent | 230a379a452e5a2bcdfd0a956b259e0a1d83b512 (diff) | |
| download | rust-b272f6ca05e9210dbe6c605a301d5a16007f322f.tar.gz rust-b272f6ca05e9210dbe6c605a301d5a16007f322f.zip | |
redox: Require scheme for path to be absolute
Redox paths are problematic. It would make sense to add a `Scheme` variant to the `std::path::Component` enum; but that would presumably be a breaking change due to exhaustive matching. Alternately it could use the existing `Prefix` variant, like Windows, but none of the existing types of prefix make sense, Redox only has one kind, and adding a new variant to that enum has the same issue as `Component`.
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/path.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 4496de09b25..866b65ac7e4 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -1685,8 +1685,16 @@ impl Path { #[stable(feature = "rust1", since = "1.0.0")] #[allow(deprecated)] pub fn is_absolute(&self) -> bool { - // FIXME: Remove target_os = "redox" and allow Redox prefixes - self.has_root() && (cfg!(unix) || cfg!(target_os = "redox") || self.prefix().is_some()) + #[cfg(not(target_os = "redox"))] + { + self.has_root() && (cfg!(unix) || self.prefix().is_some()) + } + #[cfg(target_os = "redox")] + { + // FIXME: Allow Redox prefixes + use os::unix::ffi::OsStrExt; + self.as_os_str().as_bytes().split(|b| *b == b'/').next().unwrap_or(b"").contains(&b':') + } } /// Returns `true` if the `Path` is relative, i.e. not absolute. |
