summaryrefslogblamecommitdiff
path: root/src/operations/rm.rs
blob: 846a094be35f09f627987dd797a1923e2d5a3f47 (plain) (tree)





















                                                                
use crate::EntryWriteError;
use crate::{get_entry, EntryType};
use std::path::Path;

pub fn remove<P>(path: P) -> Result<(), EntryWriteError>
where
    P: AsRef<Path>,
{
    let entry = get_entry(&path)?;
    match entry.entry_type {
        EntryType::File => std::fs::remove_file(&path)?,
        EntryType::Directory => std::fs::remove_dir_all(&path)?,
    }
    Ok(())
}

pub fn remove_file<P>(path: P) -> Result<(), EntryWriteError>
where
    P: AsRef<Path>,
{
    std::fs::remove_file(path)?;
    Ok(())
}