Enum omnipath::windows::WinPathKind
source · pub enum WinPathKind {
Drive(u16),
Unc,
Device,
CurrentDirectoryRelative,
Verbatim,
DriveRelative(u16),
RootRelative,
}
Expand description
Windows path type.
This does not do any validation so parsing the kind will never fail, even for broken or invalid paths.
Variants§
Drive(u16)
A traditional drive path such as C:\
, R:\
, etc.
Unc
A path to a network directory such as \\server\share\
.
Device
A device path such as \\.\COM1
.
CurrentDirectoryRelative
A path that’s relative to the current directory.
Verbatim
A path that is passed to the NT kernel without parsing, except to change the prefix.
These start with \\?\
, avoid DOS path length limits and can contain
paths that are otherwise illegal.
DriveRelative(u16)
A DOS drive relative path (e.g. C:file
).
RootRelative
A DOS root relative path (e.g. \file
).
Note that some Windows APIs can return paths that are relative to a
specified drive. These may start with a \
but should be joined to the
drive path instead of being treated like a DOS RootRelative
path.
Implementations§
source§impl WinPathKind
impl WinPathKind
sourcepub const fn split_str(path: &str) -> (Self, &str)
pub const fn split_str(path: &str) -> (Self, &str)
Split the path into WinPathKind
and the rest of the path.
Note that this only splits off the smallest part needed to identify the
path type. E.g. the UNC path \\server\share\file.txt
will be split
as (WinPathKind::Unc, "server\share\file.txt")
.
sourcepub const fn from_str(path: &str) -> Self
pub const fn from_str(path: &str) -> Self
Examine the path prefix to find the type of the path given.
sourcepub const fn is_absolute(self) -> bool
pub const fn is_absolute(self) -> bool
Is the path absolute. Being absolute means it doesn’t need to be joined to a base path (e.g. the current directory, or a drive current directory)
sourcepub const fn as_relative(self) -> Option<Win32Relative>
pub const fn as_relative(self) -> Option<Win32Relative>
Returns the relative path kind or None
for absolute paths.
sourcepub const fn is_legacy_relative(self) -> bool
pub const fn is_legacy_relative(self) -> bool
Is the path one of the weird ones from DOS.
These should probably be considered invalid if given from a configuration file but you may want to support them if given through command line arguments (e.g. because they come from the command prompt or a bat file).
Trait Implementations§
source§impl Clone for WinPathKind
impl Clone for WinPathKind
source§fn clone(&self) -> WinPathKind
fn clone(&self) -> WinPathKind
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for WinPathKind
impl Debug for WinPathKind
source§impl PartialEq<WinPathKind> for WinPathKind
impl PartialEq<WinPathKind> for WinPathKind
source§fn eq(&self, other: &WinPathKind) -> bool
fn eq(&self, other: &WinPathKind) -> bool
self
and other
values to be equal, and is used
by ==
.