diff --git a/src/services/fs.rs b/src/services/fs.rs index 6fbdb62..e088a6e 100644 --- a/src/services/fs.rs +++ b/src/services/fs.rs @@ -243,6 +243,45 @@ impl OpenOptions { } } +pub fn create_dir>(arch: &Archive, path: P) -> Result<(), i32> { + unsafe { + let wide = path.as_ref().as_os_str().encode_wide().collect::>(); + let ctr_path = fsMakePath(PathType::UTF16.into(), wide.as_ptr() as _); + let r = FSUSER_CreateDirectory(arch.handle, ctr_path, FS_ATTRIBUTE_DIRECTORY); + if r < 0 { + Err(r) + } else { + Ok(()) + } + } +} + +pub fn remove_dir>(arch: &Archive, path: P) -> Result<(), i32> { + unsafe { + let wide = path.as_ref().as_os_str().encode_wide().collect::>(); + let ctr_path = fsMakePath(PathType::UTF16.into(), wide.as_ptr() as _); + let r = FSUSER_DeleteDirectory(arch.handle, ctr_path); + if r < 0 { + Err(r) + } else { + Ok(()) + } + } +} + +pub fn remove_dir_all>(arch: &Archive, path: P) -> Result<(), i32> { + unsafe { + let wide = path.as_ref().as_os_str().encode_wide().collect::>(); + let ctr_path = fsMakePath(PathType::UTF16.into(), wide.as_ptr() as _); + let r = FSUSER_DeleteDirectoryRecursively(arch.handle, ctr_path); + if r < 0 { + Err(r) + } else { + Ok(()) + } + } +} + pub fn remove_file>(arch: &Archive, path: P) -> Result<(), i32> { unsafe { let wide = path.as_ref().as_os_str().encode_wide().collect::>();