pub trait GenericPath: Clone + Eq + ToStr { fn from_str(&str) -> Self; fn with_dirname(&self, &str) -> Self; fn with_filename(&self, &str) -> Self; fn file_path(&self) -> Self; fn push(&self, &str) -> Self; fn push_many<S: Str>(&self, &[S]) -> Self; fn pop(&self) -> Self; fn unsafe_join(&self, &Self) -> Self; fn is_restricted(&self) -> bool; fn normalize(&self) -> Self; fn is_absolute(&self) -> bool; fn components<'a>(&'a self) -> &'a [~str]; fn dirname(&self) -> ~str { ... } fn filename<'a>(&'a self) -> Option<&'a str> { ... } fn filestem<'a>(&'a self) -> Option<&'a str> { ... } fn filetype<'a>(&'a self) -> Option<&'a str> { ... } fn with_filestem(&self, s: &str) -> Self { ... } fn with_filetype(&self, t: &str) -> Self { ... } fn dir_path(&self) -> Self { ... } fn push_rel(&self, other: &Self) -> Self { ... } fn is_ancestor_of(&self, other: &Self) -> bool { ... } fn get_relative_to(&self, abs2: &Self) -> Self { ... } fn is_parent_of(&self, child: &Self) -> bool { ... } }
fn from_str(&str) -> Self
Converts a string to a path.
fn with_dirname(&self, &str) -> Self
Returns a new path consisting of self
with the parent directory component replaced
with the given string.
fn with_filename(&self, &str) -> Self
Returns a new path consisting of self
with the file component replaced
with the given string.
fn file_path(&self) -> Self
Returns the file component of self
, as a new path.
If self
names a directory, returns the empty path.
fn push(&self, &str) -> Self
Returns a new path whose parent directory is self
and whose
file component is the given string.
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
.
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.
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.
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
.
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.
fn is_absolute(&self) -> bool
Returns true
if self
is an absolute path.
fn components<'a>(&'a self) -> &'a [~str]
fn dirname(&self) -> ~str
Returns the directory component of self
, as a string.
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.
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.
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.
fn with_filestem(&self, s: &str) -> Self
Returns a new path consisting of self
with the file stem replaced
with the given string.
fn with_filetype(&self, t: &str) -> Self
Returns a new path consisting of self
with the file type replaced
with the given string.
fn dir_path(&self) -> Self
Returns the directory component of self
, as a new path.
If self
has no parent, returns self
.
fn push_rel(&self, other: &Self) -> Self
Returns a new path consisting of the given path, made relative to self
.
fn is_ancestor_of(&self, other: &Self) -> bool
True if self
is an ancestor of other
.
fn get_relative_to(&self, abs2: &Self) -> Self
Finds the relative path from one file to another.
fn is_parent_of(&self, child: &Self) -> bool
Returns true
iff child
is a suffix of parent
. See the test
case for examples.
Prefix searches with a type followed by a colon (e.g.
fn:
) to restrict the search to a given type.
Accepted types are: fn
, mod
,
struct
(or str
), enum
,
trait
, typedef
(or
tdef
).