1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
use std::path::PathBuf;
pub fn get_subdirectory(path: &str, offset: usize) -> String {
let p = String::from(path);
let split_path: Vec<&str> = p.split(std::path::MAIN_SEPARATOR).map(|x| x).collect();
String::from(split_path[split_path.len() - offset])
}
pub fn create_path(path_elements: Vec<&String>) -> String {
// Generate OS agnostic path String object
let mut path = PathBuf::default();
for p in path_elements.iter() {
path = path.join(p);
}
path.into_os_string().into_string().unwrap()
}