Struct std::old_path::windows::PathUnstable
[-] [+]
[src]
pub struct Path { // some fields omitted }
Represents a Windows path
Methods
impl Path
fn new<T: BytesContainer>(path: T) -> Path
Returns a new Path
from a BytesContainer
.
Panics
Panics if the vector contains a NUL
, or if it contains invalid UTF-8.
Example
fn main() { println!("{}", Path::new(r"C:\some\path").display()); }println!("{}", Path::new(r"C:\some\path").display());
fn new_opt<T: BytesContainer>(path: T) -> Option<Path>
Returns a new Some(Path)
from a BytesContainer
.
Returns None
if the vector contains a NUL
, or if it contains invalid UTF-8.
Example
fn main() { let path = Path::new_opt(r"C:\some\path"); match path { Some(path) => println!("{}", path.display()), None => println!("There was a problem with your path."), } }let path = Path::new_opt(r"C:\some\path"); match path { Some(path) => println!("{}", path.display()), None => println!("There was a problem with your path."), }
fn str_components<'a>(&'a self) -> StrComponents<'a>
Returns an iterator that yields each component of the path in turn as a Option<&str>. Every component is guaranteed to be Some. Does not yield the path prefix (including server/share components in UNC paths). Does not distinguish between volume-relative and relative paths, e.g. \a\b\c and a\b\c. Does not distinguish between absolute and cwd-relative paths, e.g. C:\foo and C:foo.
fn components<'a>(&'a self) -> Components<'a>
Returns an iterator that yields each component of the path in turn as a &[u8]. See str_components() for details.
Trait Implementations
impl Debug for Path
impl PartialEq for Path
impl Eq for Path
impl PartialOrd for Path
fn partial_cmp(&self, other: &Path) -> Option<Ordering>
fn lt(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
fn gt(&self, other: &Rhs) -> bool
fn ge(&self, other: &Rhs) -> bool
impl Ord for Path
impl FromStr for Path
type Err = ParsePathError
fn from_str(s: &str) -> Result<Path, ParsePathError>
impl Hash for Path
fn hash<H: Hasher>(&self, state: &mut H)
fn hash_slice<H>(data: &[Self], state: &mut H) where H: Hasher
impl BytesContainer for Path
fn container_as_bytes<'a>(&'a self) -> &'a [u8]
fn container_as_str<'a>(&'a self) -> Option<&'a str>
fn is_str(_: Option<&Path>) -> bool
impl GenericPathUnsafe for Path
unsafe fn new_unchecked<T: BytesContainer>(path: T) -> Path
unsafe fn set_filename_unchecked<T: BytesContainer>(&mut self, filename: T)
unsafe fn push_unchecked<T: BytesContainer>(&mut self, path: T)
See GenericPathUnsafe::push_unchecked
.
Concatenating two Windows Paths is rather complicated.
For the most part, it will behave as expected, except in the case of
pushing a volume-relative path, e.g. C:foo.txt
. Because we have no
concept of per-volume cwds like Windows does, we can't behave exactly
like Windows will. Instead, if the receiver is an absolute path on
the same volume as the new path, it will be treated as the cwd that
the new path is relative to. Otherwise, the new path will be treated
as if it were absolute and will replace the receiver outright.
impl GenericPath for Path
fn new_opt<T: BytesContainer>(path: T) -> Option<Path>
fn as_str<'a>(&'a self) -> Option<&'a str>
See GenericPath::as_str
for info.
Always returns a Some
value.
fn as_vec<'a>(&'a self) -> &'a [u8]
fn into_vec(self) -> Vec<u8>
fn dirname<'a>(&'a self) -> &'a [u8]
fn dirname_str<'a>(&'a self) -> Option<&'a str>
See GenericPath::dirname_str
for info.
Always returns a Some
value.
fn filename<'a>(&'a self) -> Option<&'a [u8]>
fn filename_str<'a>(&'a self) -> Option<&'a str>
See GenericPath::filename_str
for info.
Always returns a Some
value if filename
returns a Some
value.
fn filestem_str<'a>(&'a self) -> Option<&'a str>
See GenericPath::filestem_str
for info.
Always returns a Some
value if filestem
returns a Some
value.
fn extension_str<'a>(&'a self) -> Option<&'a str>
fn dir_path(&self) -> Path
fn pop(&mut self) -> bool
fn root_path(&self) -> Option<Path>
fn is_absolute(&self) -> bool
See GenericPath::is_absolute
for info.
A Windows Path is considered absolute only if it has a non-volume prefix,
or if it has a volume prefix and the path starts with '\'.
A path of \foo
is not considered absolute because it's actually
relative to the "current volume". A separate method Path::is_vol_relative
is provided to indicate this case. Similarly a path of C:foo
is not
considered absolute because it's relative to the cwd on volume C:. A
separate method Path::is_cwd_relative
is provided to indicate this case.