diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2018-08-22 13:19:32 -0400 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2018-08-22 18:39:07 -0400 |
commit | 7d7263c48f4280f8da5496273e85fb1a8fb79547 (patch) | |
tree | 709df115d6d2daf5a753a31a69bac637d65a33a7 /src/fs.rs | |
parent | e7cab715749e4c5000c24ffeade1ef915d15a68d (diff) |
Implement writeFileSync
In collaboration with Tommy Savaria <tommy.savaria@protonmail.ch>
Diffstat (limited to 'src/fs.rs')
-rw-r--r-- | src/fs.rs | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -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"); |