Skip to content

Commit

Permalink
Rollup merge of rust-lang#45892 - redox-os:is_absolute_fix, r=alexcri…
Browse files Browse the repository at this point in the history
…chton

Redox: Return true from Path::is_absolute if a Path contains root or a scheme

In Redox, different subsystems have different filesystem paths. However, the majority of applications using the `Path::is_absolute` function really only want to know if a path is absolute from the perspective of the scheme it is currently running in, usually `file:`. This makes both `file:/` and `/` return `true` from `Path::is_absolute`, meaning that most code does not have to check if it is running on Redox.

Code that wants to know if a path contains a scheme can implement such a check on its own.

Related to rust-lang#45893
  • Loading branch information
kennytm authored Nov 13, 2017
2 parents e3ca816 + ef76ebf commit 563af5d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/libstd/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1690,11 +1690,11 @@ impl Path {
#[stable(feature = "rust1", since = "1.0.0")]
#[allow(deprecated)]
pub fn is_absolute(&self) -> bool {
if !cfg!(target_os = "redox") {
self.has_root() && (cfg!(unix) || self.prefix().is_some())
} else {
if cfg!(target_os = "redox") {
// FIXME: Allow Redox prefixes
has_redox_scheme(self.as_u8_slice())
self.has_root() || has_redox_scheme(self.as_u8_slice())
} else {
self.has_root() && (cfg!(unix) || self.prefix().is_some())
}
}

Expand Down

0 comments on commit 563af5d

Please sign in to comment.