summaryrefslogtreecommitdiff
path: root/src/fs.rs
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2018-08-22 13:19:32 -0400
committerRyan Dahl <ry@tinyclouds.org>2018-08-22 18:39:07 -0400
commit7d7263c48f4280f8da5496273e85fb1a8fb79547 (patch)
tree709df115d6d2daf5a753a31a69bac637d65a33a7 /src/fs.rs
parente7cab715749e4c5000c24ffeade1ef915d15a68d (diff)
Implement writeFileSync
In collaboration with Tommy Savaria <tommy.savaria@protonmail.ch>
Diffstat (limited to 'src/fs.rs')
-rw-r--r--src/fs.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/fs.rs b/src/fs.rs
index 0aaf2a93d..9191d5373 100644
--- a/src/fs.rs
+++ b/src/fs.rs
@@ -1,6 +1,7 @@
use std;
use std::fs::File;
use std::io::Read;
+use std::io::Write;
use std::path::Path;
pub fn read_file_sync(path: &Path) -> std::io::Result<Vec<u8>> {
@@ -17,6 +18,11 @@ pub fn read_file_sync_string(path: &Path) -> std::io::Result<String> {
.map_err(|err| std::io::Error::new(std::io::ErrorKind::InvalidData, err))
}
+pub fn write_file_sync(path: &Path, content: &[u8]) -> std::io::Result<()> {
+ let mut f = File::create(path)?;
+ f.write_all(content)
+}
+
pub fn mkdir(path: &Path) -> std::io::Result<()> {
debug!("mkdir -p {}", path.display());
assert!(path.has_root(), "non-has_root not yet implemented");