use std::path::{Path, PathBuf};
use crate::{PathType, PavedPath};
impl PavedPath {
pub fn new(path_type: PathType) -> Self {
let mut new_path = Self {
path_type,
path_prefix: None,
directories: Vec::new(),
file: None,
inner: PathBuf::new(),
};
new_path.rebuild_inner();
new_path
}
pub fn new_relative() -> Self {
Self::new(PathType::Relative)
}
pub fn new_absolute() -> Self {
Self::new(PathType::Absolute)
}
pub fn from_dirs_path(dirs: impl AsRef<Path>) -> Self {
let mut paved = Self::from(dirs.as_ref());
if let Some(file) = paved.get_file() {
let file = file.clone();
paved = paved.without_file().with_dir(file);
}
paved
}
}