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`.
#[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.