Cross-platform file path handling

Struct PosixPath

pub struct PosixPath {
    is_absolute: bool,
    components: ~[~str],
}

Struct WindowsPath

pub struct WindowsPath {
    host: Option<~str>,
    device: Option<~str>,
    is_absolute: bool,
    components: ~[~str],
}

Trait GenericPath

Method from_str

fn from_str(&str) -> Self

Converts a string to a path.

Method dirname

fn dirname(&self) -> ~str

Returns the directory component of self, as a string.

Method filename

fn filename<'a>(&'a self) -> Option<&'a str>

Returns the file component of self, as a string option. Returns None if self names a directory.

Method filestem

fn filestem<'a>(&'a self) -> Option<&'a str>

Returns the stem of the file component of self, as a string option. The stem is the slice of a filename starting at 0 and ending just before the last '.' in the name. Returns None if self names a directory.

Method filetype

fn filetype<'a>(&'a self) -> Option<&'a str>

Returns the type of the file component of self, as a string option. The file type is the slice of a filename starting just after the last '.' in the name and ending at the last index in the filename. Returns None if self names a directory.

Method with_dirname

fn with_dirname(&self, &str) -> Self

Returns a new path consisting of self with the parent directory component replaced with the given string.

Method with_filename

fn with_filename(&self, &str) -> Self

Returns a new path consisting of self with the file component replaced with the given string.

Method with_filestem

fn with_filestem(&self, s: &str) -> Self

Returns a new path consisting of self with the file stem replaced with the given string.

Method with_filetype

fn with_filetype(&self, t: &str) -> Self

Returns a new path consisting of self with the file type replaced with the given string.

Method dir_path

fn dir_path(&self) -> Self

Returns the directory component of self, as a new path. If self has no parent, returns self.

Method file_path

fn file_path(&self) -> Self

Returns the file component of self, as a new path. If self names a directory, returns the empty path.

Method push

fn push(&self, &str) -> Self

Returns a new path whose parent directory is self and whose file component is the given string.

Method push_rel

fn push_rel(&self, other: &Self) -> Self

Returns a new path consisting of the given path, made relative to self.

Method push_many

fn push_many<S: Str>(&self, &[S]) -> Self

Returns a new path consisting of the path given by the given vector of strings, relative to self.

Method pop

fn pop(&self) -> Self

Identical to dir_path except in the case where self has only one component. In this case, pop returns the empty path.

Method unsafe_join

fn unsafe_join(&self, &Self) -> Self

The same as push_rel, except that the directory argument must not contain directory separators in any of its components.

Method is_restricted

fn is_restricted(&self) -> bool

On Unix, always returns false. On Windows, returns true iff self's file stem is one of: con aux com1 com2 com3 com4 lpt1 lpt2 lpt3 prn nul.

Method normalize

fn normalize(&self) -> Self

Returns a new path that names the same file as self, without containing any '.', '..', or empty components. On Windows, uppercases the drive letter as well.

Method is_absolute

fn is_absolute(&self) -> bool

Returns true if self is an absolute path.

Method is_ancestor_of

fn is_ancestor_of(&self, other: &Self) -> bool

True if self is an ancestor of other.

Method get_relative_to

fn get_relative_to(&self, abs2: &Self) -> Self

Finds the relative path from one file to another.

Method components

fn components<'a>(&'a self) -> &'a [~str]

Implementation of ::std::clone::Clone for WindowsPath

Automatically derived.

Method clone

fn clone(&self) -> WindowsPath

Implementation of ::std::cmp::Eq for WindowsPath

Automatically derived.

Method eq

fn eq(&self, __arg_0: &WindowsPath) -> ::bool

Method ne

fn ne(&self, __arg_0: &WindowsPath) -> ::bool

Implementation of ::std::clone::Clone for PosixPath

Automatically derived.

Method clone

fn clone(&self) -> PosixPath

Implementation of ::std::cmp::Eq for PosixPath

Automatically derived.

Method eq

fn eq(&self, __arg_0: &PosixPath) -> ::bool

Method ne

fn ne(&self, __arg_0: &PosixPath) -> ::bool

Implementation for PosixPath

Method stat

fn stat(&self) -> Option<libc::stat>

Method exists

fn exists(&self) -> bool

Method get_size

fn get_size(&self) -> Option<i64>

Method get_mode

fn get_mode(&self) -> Option<uint>

Method each_parent

fn each_parent(&self, f: &fn(&Path))

Executes a function f on self as well as on all of its ancestors.

Implementation for PosixPath

Method get_atime

fn get_atime(&self) -> Option<(i64, int)>

Method get_mtime

fn get_mtime(&self) -> Option<(i64, int)>

Method get_ctime

fn get_ctime(&self) -> Option<(i64, int)>

Implementation for PosixPath

Method lstat

fn lstat(&self) -> Option<libc::stat>

Implementation of ToStr for PosixPath

Method to_str

fn to_str(&self) -> ~str

Implementation of ToCStr for PosixPath

Method to_c_str

fn to_c_str(&self) -> c_str::CString

Method to_c_str_unchecked

unsafe fn to_c_str_unchecked(&self) -> c_str::CString

Implementation of GenericPath for PosixPath

Method from_str

fn from_str(s: &str) -> PosixPath

Method with_dirname

fn with_dirname(&self, d: &str) -> PosixPath

Method with_filename

fn with_filename(&self, f: &str) -> PosixPath

Method file_path

fn file_path(&self) -> PosixPath

Method push

fn push(&self, s: &str) -> PosixPath

Method push_many

fn push_many<S: Str>(&self, cs: &[S]) -> PosixPath

Method pop

fn pop(&self) -> PosixPath

Method unsafe_join

fn unsafe_join(&self, other: &PosixPath) -> PosixPath

Method is_restricted

fn is_restricted(&self) -> bool

Method normalize

fn normalize(&self) -> PosixPath

Method is_absolute

fn is_absolute(&self) -> bool

Method components

fn components<'a>(&'a self) -> &'a [~str]

Implementation of ToStr for WindowsPath

Method to_str

fn to_str(&self) -> ~str

Implementation of c_str::ToCStr for WindowsPath

Method to_c_str

fn to_c_str(&self) -> c_str::CString

Method to_c_str_unchecked

unsafe fn to_c_str_unchecked(&self) -> c_str::CString

Implementation of GenericPath for WindowsPath

Method from_str

fn from_str(s: &str) -> WindowsPath

Method with_dirname

fn with_dirname(&self, d: &str) -> WindowsPath

Method with_filename

fn with_filename(&self, f: &str) -> WindowsPath

Method file_path

fn file_path(&self) -> WindowsPath

Method push

fn push(&self, s: &str) -> WindowsPath

Method push_many

fn push_many<S: Str>(&self, cs: &[S]) -> WindowsPath

Method pop

fn pop(&self) -> WindowsPath

Method unsafe_join

fn unsafe_join(&self, other: &WindowsPath) -> WindowsPath

Method is_restricted

fn is_restricted(&self) -> bool

Method normalize

fn normalize(&self) -> WindowsPath

Method is_absolute

fn is_absolute(&self) -> bool

Method components

fn components<'a>(&'a self) -> &'a [~str]

Function PosixPath

fn PosixPath(s: &str) -> PosixPath

Function WindowsPath

fn WindowsPath(s: &str) -> WindowsPath

Function normalize

fn normalize(components: &[~str]) -> ~[~str]