Simplify code for handling Redox paths
This commit is contained in:
parent
ab48de8847
commit
fe2d661931
1 changed files with 5 additions and 10 deletions
|
@ -324,9 +324,7 @@ unsafe fn u8_slice_as_os_str(s: &[u8]) -> &OsStr {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Detect scheme on Redox
|
// Detect scheme on Redox
|
||||||
#[inline]
|
fn has_redox_scheme(s: &[u8]) -> bool {
|
||||||
#[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!(target_os = "redox") && s.split(|b| *b == b'/').next().unwrap_or(b"").contains(&b':')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -612,9 +610,6 @@ 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,
|
||||||
|
@ -735,7 +730,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 || self.has_scheme {
|
if self.has_physical_root {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if let Some(p) = self.prefix {
|
if let Some(p) = self.prefix {
|
||||||
|
@ -1699,7 +1694,7 @@ impl Path {
|
||||||
self.has_root() && (cfg!(unix) || self.prefix().is_some())
|
self.has_root() && (cfg!(unix) || self.prefix().is_some())
|
||||||
} else {
|
} else {
|
||||||
// FIXME: Allow Redox prefixes
|
// FIXME: Allow Redox prefixes
|
||||||
has_scheme(self.as_u8_slice())
|
has_redox_scheme(self.as_u8_slice())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2064,8 +2059,8 @@ impl Path {
|
||||||
Components {
|
Components {
|
||||||
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()),
|
has_redox_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