Correct has_root() on Redox
This commit is contained in:
parent
b272f6ca05
commit
e0f0fd08b5
1 changed files with 20 additions and 3 deletions
|
@ -323,6 +323,20 @@ unsafe fn u8_slice_as_os_str(s: &[u8]) -> &OsStr {
|
||||||
mem::transmute(s)
|
mem::transmute(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Detect scheme on Redox
|
||||||
|
#[inline]
|
||||||
|
#[allow(unused_variables)]
|
||||||
|
fn has_scheme(s: &[u8]) -> bool {
|
||||||
|
#[cfg(target_os = "redox")]
|
||||||
|
{
|
||||||
|
s.split(|b| *b == b'/').next().unwrap_or(b"").contains(&b':')
|
||||||
|
}
|
||||||
|
#[cfg(not(target_os = "redox"))]
|
||||||
|
{
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Cross-platform, iterator-independent parsing
|
// Cross-platform, iterator-independent parsing
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -605,6 +619,9 @@ pub struct Components<'a> {
|
||||||
// normalization, e.g. \\server\share == \\server\share\.
|
// normalization, e.g. \\server\share == \\server\share\.
|
||||||
has_physical_root: bool,
|
has_physical_root: bool,
|
||||||
|
|
||||||
|
// For Redox
|
||||||
|
has_scheme: bool,
|
||||||
|
|
||||||
// The iterator is double-ended, and these two states keep track of what has
|
// The iterator is double-ended, and these two states keep track of what has
|
||||||
// been produced from either end
|
// been produced from either end
|
||||||
front: State,
|
front: State,
|
||||||
|
@ -725,7 +742,7 @@ impl<'a> Components<'a> {
|
||||||
|
|
||||||
/// Is the *original* path rooted?
|
/// Is the *original* path rooted?
|
||||||
fn has_root(&self) -> bool {
|
fn has_root(&self) -> bool {
|
||||||
if self.has_physical_root {
|
if self.has_physical_root || self.has_scheme {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if let Some(p) = self.prefix {
|
if let Some(p) = self.prefix {
|
||||||
|
@ -1692,8 +1709,7 @@ impl Path {
|
||||||
#[cfg(target_os = "redox")]
|
#[cfg(target_os = "redox")]
|
||||||
{
|
{
|
||||||
// FIXME: Allow Redox prefixes
|
// FIXME: Allow Redox prefixes
|
||||||
use os::unix::ffi::OsStrExt;
|
has_scheme(self.as_u8_slice())
|
||||||
self.as_os_str().as_bytes().split(|b| *b == b'/').next().unwrap_or(b"").contains(&b':')
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2059,6 +2075,7 @@ impl Path {
|
||||||
path: self.as_u8_slice(),
|
path: self.as_u8_slice(),
|
||||||
prefix,
|
prefix,
|
||||||
has_physical_root: has_physical_root(self.as_u8_slice(), prefix),
|
has_physical_root: has_physical_root(self.as_u8_slice(), prefix),
|
||||||
|
has_scheme: has_scheme(self.as_u8_slice()),
|
||||||
front: State::Prefix,
|
front: State::Prefix,
|
||||||
back: State::Body,
|
back: State::Body,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue