Initial commit

Signed-off-by: Marko Korhonen <marko.korhonen@reekynet.com>
This commit is contained in:
Marko Korhonen 2020-01-19 21:33:52 +02:00
commit 5f81577b83
No known key found for this signature in database
GPG key ID: 911B85FBC6003FE5
7 changed files with 398 additions and 0 deletions

22
src/fs.rs Normal file
View file

@ -0,0 +1,22 @@
use std::fs::{remove_file, File};
use std::io::prelude::*;
use std::path::PathBuf;
pub fn write(path: &PathBuf, contents: String) -> std::io::Result<()> {
let mut file = File::create(path)?;
file.write_all(contents.as_bytes())?;
file.sync_data()?;
Ok(())
}
pub fn read(path: &PathBuf) -> std::io::Result<String> {
let mut file = File::open(path)?;
let mut contents = String::new();
file.read_to_string(&mut contents)?;
Ok(contents)
}
pub fn remove(path: &PathBuf) -> std::io::Result<()> {
remove_file(path)?;
Ok(())
}