This repository has been archived on 2024-11-26. You can view files and clone it, but cannot push or open issues or pull requests.
sysforge/src/file.rs

25 lines
697 B
Rust
Raw Normal View History

2024-11-25 19:40:00 +01:00
// SPDX-License-Identifier: LGPL-3.0-or-later
// Copyright (c) 2024 Patrick_Pluto
2024-11-25 19:37:22 +01:00
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
}