pub trait PathExt{
// Required methods
fn basename(&self) -> String;
fn filename(&self) -> Cow<'_, str>;
fn _filename(&self) -> Result<&str, StringError>;
fn display_short(&self, _: &Path) -> String;
fn len(&self) -> usize;
fn is_hidden(&self) -> bool;
fn abs(&self, _: impl AsRef<Path>) -> PathBuf;
fn is_empty(&self) -> bool;
fn normalize(&self) -> PathBuf;
fn shell_quote(&self) -> Option<String>;
}Required Methods§
Sourcefn basename(&self) -> String
fn basename(&self) -> String
Get the owned (lossy) basename of a valid path (for display purposes). Returns the original if path has no filename.
Sourcefn filename(&self) -> Cow<'_, str>
fn filename(&self) -> Cow<'_, str>
Get the (lossy) basename of a valid path. Returns empty string + log::warn! if path has no filename.
Sourcefn _filename(&self) -> Result<&str, StringError>
fn _filename(&self) -> Result<&str, StringError>
Convert to str, or provide useful error.
fn display_short(&self, _: &Path) -> String
fn len(&self) -> usize
Robustly determine whether a file is hidden
Sourcefn abs(&self, _: impl AsRef<Path>) -> PathBuf
fn abs(&self, _: impl AsRef<Path>) -> PathBuf
Prepend base to current path then normalize.
§Example
use std::path::Path;
use cba::{bog::{BogOkExt, BogUnwrapExt}, bath::PathExt, bait::OptionExt};
let path = Path::new("");
path.abs(std::env::current_dir()._ebog().or_exit());fn is_empty(&self) -> bool
Sourcefn normalize(&self) -> PathBuf
fn normalize(&self) -> PathBuf
clean path logically (so that all components are Component::Normal)
Sourcefn shell_quote(&self) -> Option<String>
fn shell_quote(&self) -> Option<String>
Quotes the path. Returns None if not Windows or Unix or not UTF-8.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.