summaryrefslogtreecommitdiff
path: root/src/operations.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/operations.rs')
-rw-r--r--src/operations.rs31
1 files changed, 13 insertions, 18 deletions
diff --git a/src/operations.rs b/src/operations.rs
index 54ce8c7..dd0a132 100644
--- a/src/operations.rs
+++ b/src/operations.rs
@@ -1,30 +1,25 @@
use crate::*;
-use std::path::Path;
-
-mod ls;
-pub use ls::*;
mod cp;
-pub use cp::*;
-
+mod ls;
+mod mkdir;
mod rm;
-pub use rm::*;
-mod mkdir;
+pub use cp::*;
+pub use ls::*;
pub use mkdir::*;
+pub use rm::*;
-pub fn append_to_file<P>(_path: P, _content: &str) -> Result<(), EntryWriteError>
-where
- P: AsRef<Path>,
-{
+/// Append bytes to the end of a file.
+#[must_use]
+pub fn append_to_file(_path: impl AsRef<Path>, _content: &str) -> WriteResult<()> {
unimplemented!()
}
-pub fn write_to_file<P>(path: P, content: &str) -> Result<(), EntryWriteError>
-where
- P: AsRef<Path>,
-{
+/// 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)?;
- std::fs::write(&path, content)?;
- Ok(())
+ let write_result = std::fs::write(&path, content);
+ Ok(io_result_to_write_result(write_result, path.as_ref())?)
}