From b272f6ca05e9210dbe6c605a301d5a16007f322f Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Fri, 18 Aug 2017 12:04:45 -0700 Subject: 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`. --- src/libstd/path.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/libstd') 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. -- cgit 1.4.1-3-g733a5