Skip to main content

file_storage/path/construct/
cwd.rs

1use crate::{Error, FolderPath, StoragePath};
2use std::io;
3
4impl FolderPath {
5    //! Current Working Directory
6
7    /// Gets the current working directory.
8    pub fn current_working_directory() -> Result<Self, io::Error> {
9        let path: std::path::PathBuf = std::env::current_dir()?;
10        match path.into_os_string().into_string() {
11            Ok(path) => Ok(StoragePath::parse(path)?.make_folder()),
12            Err(os) => Err(Error::path_not_utf8(os.as_ref())),
13        }
14    }
15}