use crate::*;

#[must_use]
pub fn remove(path: impl AsRef<Path>) -> WriteResult<()> {
    let entry = get_entry(&path)?;
    let remove_result = match entry.entry_type {
        EntryType::File => std::fs::remove_file(&path),
        EntryType::Directory => std::fs::remove_dir_all(&path),
    };
    Ok(io_result_to_write_result(remove_result, path.as_ref())?)
}

#[must_use]
pub fn remove_file(path: impl AsRef<Path>) -> WriteResult<()> {
    let remove_result = std::fs::remove_file(&path);
    Ok(io_result_to_write_result(remove_result, &path.as_ref())?)
}