Skip to content

Commit b272f6c

Browse files
committed
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`.
1 parent 230a379 commit b272f6c

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/libstd/path.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,8 +1685,16 @@ impl Path {
16851685
#[stable(feature = "rust1", since = "1.0.0")]
16861686
#[allow(deprecated)]
16871687
pub fn is_absolute(&self) -> bool {
1688-
// FIXME: Remove target_os = "redox" and allow Redox prefixes
1689-
self.has_root() && (cfg!(unix) || cfg!(target_os = "redox") || self.prefix().is_some())
1688+
#[cfg(not(target_os = "redox"))]
1689+
{
1690+
self.has_root() && (cfg!(unix) || self.prefix().is_some())
1691+
}
1692+
#[cfg(target_os = "redox")]
1693+
{
1694+
// FIXME: Allow Redox prefixes
1695+
use os::unix::ffi::OsStrExt;
1696+
self.as_os_str().as_bytes().split(|b| *b == b'/').next().unwrap_or(b"").contains(&b':')
1697+
}
16901698
}
16911699

16921700
/// Returns `true` if the `Path` is relative, i.e. not absolute.

0 commit comments

Comments
 (0)