Skip to content

Commit

Permalink
Move create function to write function
Browse files Browse the repository at this point in the history
  • Loading branch information
kpcyrd committed Apr 25, 2021
1 parent f7ca7ab commit 713632f
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/persist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,6 @@ pub struct FilePersist {
path: PathBuf,
}

fn create(path: &Path, mode: u32) -> Result<File> {
OpenOptions::new()
.write(true)
.create(true)
.truncate(true)
.mode(mode)
.open(path)
.map_err(Error::from)
}

impl FilePersist {
pub fn new(config: &Config) -> FilePersist {
FilePersist {
Expand Down Expand Up @@ -204,6 +194,16 @@ impl FilePersist {
}
}

fn create(path: &Path, mode: u32) -> Result<File> {
OpenOptions::new()
.write(true)
.create(true)
.truncate(true)
.mode(mode)
.open(path)
.map_err(Error::from)
}

fn write(path: &Path, mode: u32, data: &[u8]) -> Result<()> {
let mut f = create(&path, mode)?;
f.write_all(data)?;
Expand Down

0 comments on commit 713632f

Please sign in to comment.