Cross-platform file path handling
PosixPath
WindowsPath
GenericPath
of ::std::clone::Clone for WindowsPath
- Automatically derived.of ::std::cmp::Eq for WindowsPath
- Automatically derived.of ::std::clone::Clone for PosixPath
- Automatically derived.of ::std::cmp::Eq for PosixPath
- Automatically derived.for PosixPath
for PosixPath
for PosixPath
of ToStr for PosixPath
of ToCStr for PosixPath
of GenericPath for PosixPath
of ToStr for WindowsPath
of c_str::ToCStr for WindowsPath
of GenericPath for WindowsPath
PosixPath
WindowsPath
normalize
path::posix
path::windows
PosixPath
pub struct PosixPath {
is_absolute: bool,
components: ~[~str],
}
WindowsPath
pub struct WindowsPath {
host: Option<~str>,
device: Option<~str>,
is_absolute: bool,
components: ~[~str],
}
GenericPath
from_str
fn from_str(&str) -> Self
Converts a string to a path.
dirname
fn dirname(&self) -> ~str
Returns the directory component of self
, as a string.
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.
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.
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.
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.
with_filename
fn with_filename(&self, &str) -> Self
Returns a new path consisting of self
with the file component replaced with the given string.
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.
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.
dir_path
fn dir_path(&self) -> Self
Returns the directory component of self
, as a new path. If self
has no parent, returns self
.
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.
push
fn push(&self, &str) -> Self
Returns a new path whose parent directory is self
and whose file component is the given string.
push_rel
fn push_rel(&self, other: &Self) -> Self
Returns a new path consisting of the given path, made relative to self
.
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
.
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.
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.
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
.
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.
is_absolute
fn is_absolute(&self) -> bool
Returns true
if self
is an absolute path.
is_ancestor_of
fn is_ancestor_of(&self, other: &Self) -> bool
True if self
is an ancestor of other
.
get_relative_to
fn get_relative_to(&self, abs2: &Self) -> Self
Finds the relative path from one file to another.
components
fn components<'a>(&'a self) -> &'a [~str]
::std::clone::Clone
for WindowsPath
Automatically derived.
clone
fn clone(&self) -> WindowsPath
::std::cmp::Eq
for WindowsPath
Automatically derived.
eq
fn eq(&self, __arg_0: &WindowsPath) -> ::bool
ne
fn ne(&self, __arg_0: &WindowsPath) -> ::bool
::std::clone::Clone
for PosixPath
Automatically derived.
clone
fn clone(&self) -> PosixPath
::std::cmp::Eq
for PosixPath
Automatically derived.
eq
fn eq(&self, __arg_0: &PosixPath) -> ::bool
ne
fn ne(&self, __arg_0: &PosixPath) -> ::bool
PosixPath
stat
fn stat(&self) -> Option<libc::stat>
exists
fn exists(&self) -> bool
get_size
fn get_size(&self) -> Option<i64>
get_mode
fn get_mode(&self) -> Option<uint>
each_parent
fn each_parent(&self, f: &fn(&Path))
Executes a function f
on self
as well as on all of its ancestors.
PosixPath
get_atime
fn get_atime(&self) -> Option<(i64, int)>
get_mtime
fn get_mtime(&self) -> Option<(i64, int)>
get_ctime
fn get_ctime(&self) -> Option<(i64, int)>
PosixPath
lstat
fn lstat(&self) -> Option<libc::stat>
ToStr
for PosixPath
to_str
fn to_str(&self) -> ~str
ToCStr
for PosixPath
to_c_str
fn to_c_str(&self) -> c_str::CString
to_c_str_unchecked
unsafe fn to_c_str_unchecked(&self) -> c_str::CString
GenericPath
for PosixPath
from_str
fn from_str(s: &str) -> PosixPath
with_dirname
fn with_dirname(&self, d: &str) -> PosixPath
with_filename
fn with_filename(&self, f: &str) -> PosixPath
file_path
fn file_path(&self) -> PosixPath
push
fn push(&self, s: &str) -> PosixPath
push_many
fn push_many<S: Str>(&self, cs: &[S]) -> PosixPath
pop
fn pop(&self) -> PosixPath
unsafe_join
fn unsafe_join(&self, other: &PosixPath) -> PosixPath
is_restricted
fn is_restricted(&self) -> bool
normalize
fn normalize(&self) -> PosixPath
is_absolute
fn is_absolute(&self) -> bool
components
fn components<'a>(&'a self) -> &'a [~str]
ToStr
for WindowsPath
to_str
fn to_str(&self) -> ~str
c_str::ToCStr
for WindowsPath
to_c_str
fn to_c_str(&self) -> c_str::CString
to_c_str_unchecked
unsafe fn to_c_str_unchecked(&self) -> c_str::CString
GenericPath
for WindowsPath
from_str
fn from_str(s: &str) -> WindowsPath
with_dirname
fn with_dirname(&self, d: &str) -> WindowsPath
with_filename
fn with_filename(&self, f: &str) -> WindowsPath
file_path
fn file_path(&self) -> WindowsPath
push
fn push(&self, s: &str) -> WindowsPath
push_many
fn push_many<S: Str>(&self, cs: &[S]) -> WindowsPath
pop
fn pop(&self) -> WindowsPath
unsafe_join
fn unsafe_join(&self, other: &WindowsPath) -> WindowsPath
is_restricted
fn is_restricted(&self) -> bool
normalize
fn normalize(&self) -> WindowsPath
is_absolute
fn is_absolute(&self) -> bool
components
fn components<'a>(&'a self) -> &'a [~str]
PosixPath
fn PosixPath(s: &str) -> PosixPath
WindowsPath
fn WindowsPath(s: &str) -> WindowsPath
normalize
fn normalize(components: &[~str]) -> ~[~str]