Skip to content

Commit

Permalink
chore: add fs read (paradigmxyz#5706)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Dec 6, 2023
1 parent 857f907 commit 3947b91
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions crates/primitives/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@ pub fn read_to_string(path: impl AsRef<Path>) -> Result<String> {
fs::read_to_string(path).map_err(|err| FsPathError::read(err, path))
}

/// Read the entire contents of a file into a bytes vector.
///
/// Wrapper for `std::fs::read`
pub fn read(path: impl AsRef<Path>) -> Result<Vec<u8>> {
let path = path.as_ref();
fs::read(path).map_err(|err| FsPathError::read(err, path))
}

/// Wrapper for `std::fs::write`
pub fn write(path: impl AsRef<Path>, contents: impl AsRef<[u8]>) -> Result<()> {
let path = path.as_ref();
Expand Down

0 comments on commit 3947b91

Please sign in to comment.