use crate::*;

mod cp;
mod ls;
mod mkdir;
mod rm;

pub use cp::*;
pub use ls::*;
pub use mkdir::*;
pub use rm::*;

/// Append bytes to the end of a file.
#[must_use]
pub fn append_to_file(_path: impl AsRef<Path>, _content: &str) -> WriteResult<()> {
    unimplemented!()
}

/// Write a slice of bytes to a file, overwriting the existing file if it already exists.
#[must_use]
pub fn write_to_file(path: impl AsRef<Path>, content: impl AsRef<[u8]>) -> WriteResult<()> {
    make_parent_directory(&path)?;
    let write_result = std::fs::write(&path, content);
    Ok(io_result_to_write_result(write_result, path.as_ref())?)
}