22 lines
614 B
Rust
22 lines
614 B
Rust
|
use std::fs::File;
|
||
|
use std::io::{Read, Write};
|
||
|
|
||
|
pub fn load_file(file_path: &str) -> String {
|
||
|
let mut file: File = File::open(file_path).unwrap();
|
||
|
let mut contents: String = String::new();
|
||
|
let _ = file.read_to_string(&mut contents);
|
||
|
contents
|
||
|
}
|
||
|
|
||
|
pub fn save_binary_u8(file_path: &str, content: Vec<u8>) {
|
||
|
let mut file: File = File::create(file_path).unwrap();
|
||
|
file.write_all(&content).unwrap();
|
||
|
}
|
||
|
|
||
|
pub fn load_binary_u8(file_path: &str) -> Vec<u8> {
|
||
|
let mut file = File::open(file_path).unwrap();
|
||
|
let mut buffer = Vec::new();
|
||
|
file.read_to_end(&mut buffer).unwrap();
|
||
|
buffer
|
||
|
}
|