Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is absolute #5971

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions src/libcore/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ pub trait GenericPath {
fn is_restricted(&self) -> bool;

fn normalize(&self) -> Self;

fn is_absolute(&self) -> bool;
}

#[cfg(windows)]
Expand Down Expand Up @@ -379,10 +381,11 @@ impl ToStr for PosixPath {
// FIXME (#3227): when default methods in traits are working, de-duplicate
// PosixPath and WindowsPath, most of their methods are common.
impl GenericPath for PosixPath {

fn from_str(s: &str) -> PosixPath {
let mut components = ~[];
for str::each_split_nonempty(s, |c| c == '/') |s| { components.push(s.to_owned()) }
for str::each_split_nonempty(s, |c| c == '/') |s| {
components.push(s.to_owned())
}
let is_absolute = (s.len() != 0 && s[0] == '/' as u8);
return PosixPath { is_absolute: is_absolute,
components: components }
Expand Down Expand Up @@ -540,6 +543,10 @@ impl GenericPath for PosixPath {
// ..self
}
}

fn is_absolute(&self) -> bool {
self.is_absolute
}
}


Expand All @@ -563,7 +570,6 @@ impl ToStr for WindowsPath {


impl GenericPath for WindowsPath {

fn from_str(s: &str) -> WindowsPath {
let host;
let device;
Expand Down Expand Up @@ -809,6 +815,10 @@ impl GenericPath for WindowsPath {
components: normalize(self.components)
}
}

fn is_absolute(&self) -> bool {
self.is_absolute
}
}


Expand Down