diff --git a/src/utils/fs.rs b/src/utils/fs.rs index e3930d8..ca46ee6 100644 --- a/src/utils/fs.rs +++ b/src/utils/fs.rs @@ -2,17 +2,6 @@ use std::fs; use std::io::{self, Read}; use std::path; -/// Ensure a directory exists, creating it with parents if necessary. -pub fn ensure_dir_exists(path: &path::Path) -> Result<(), io::Error> { - if !path.is_dir() { - if path.exists() { - return Err(io::Error::new(io::ErrorKind::AlreadyExists, "Not a directory.")); - } - fs::create_dir_all(&path)?; - } - Ok(()) -} - /// Strip the extension from a file path. pub fn strip_extension(path: &path::PathBuf) -> Option { let mut pb = path::PathBuf::from(&path); @@ -33,6 +22,17 @@ pub fn open_file_to_vec(path: &path::Path) -> Result, io::Error> { Ok(data) } +/// Ensure a directory exists, creating it with parents if necessary. +pub fn ensure_dir_exists(path: &path::Path) -> Result<(), io::Error> { + if !path.is_dir() { + if path.exists() { + return Err(io::Error::new(io::ErrorKind::AlreadyExists, "Not a directory.")); + } + fs::create_dir_all(&path)?; + } + Ok(()) +} + #[cfg(test)] mod tests { use super::*;