mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-15 06:12:18 +00:00
17 lines
383 B
Rust
17 lines
383 B
Rust
use std::fs::File;
|
|
use std::io;
|
|
use std::io::{BufReader, Read};
|
|
use std::path::Path;
|
|
|
|
/// Read a file into a byte buffer
|
|
pub fn file_read_bytes<P: AsRef<Path>>(file_path: P) -> io::Result<Vec<u8>> {
|
|
let f = File::open(file_path)?;
|
|
let mut reader = BufReader::new(f);
|
|
let mut buffer = Vec::new();
|
|
|
|
// Read file into vector.
|
|
reader.read_to_end(&mut buffer)?;
|
|
|
|
Ok(buffer)
|
|
}
|