Skip to main content

file_storage/path/construct/
cwd.rs

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