Expand description
Work with file paths by text only.
In the Windows operating system, absolute paths may either start with a drive letter followed by
a colon or an UNC path prefix (\\
). Therefore, this crate provides
a FlexPath
that is based on a variant ([FlexPathVariant]), which you don’t need to always
specify. This variant indicates whether to interpret Windows absolute paths
or not.
There are two FlexPathVariant variants currently:
- Common
- Windows
The constant FlexPathVariant::NATIVE
is one of these variants
based on the target platform. For the Windows operating system, it
is always Windows. For other platforms, it’s always Common.
§Example
use file_paths::FlexPath;
assert_eq!("a", FlexPath::new_common("a/b").resolve("..").to_string());
assert_eq!("a", FlexPath::new_common("a/b/..").to_string());
assert_eq!("a/b/c/d/e", FlexPath::from_n_common(["a/b", "c/d", "e/f", ".."]).to_string());
assert_eq!("../../c/d", FlexPath::new_common("/a/b").relative("/c/d"));
Structs§
- Flex
Path - The
FlexPath
structure represents an always-resolved textual file path based on a [FlexPathVariant].
Enums§
- Flex
Path Variant - Indicates if special absolute paths are considered.