16 lines
419 B
Rust
16 lines
419 B
Rust
use memmap::*;
|
|
|
|
// TODO: 打开文件,并将文件映射到内存
|
|
pub fn mmap_mut_file(file_path: &str) -> Result<MmapMut, std::io::Error> {
|
|
let file = std::fs::OpenOptions::new()
|
|
.read(true)
|
|
.write(true)
|
|
.open(file_path)?;
|
|
|
|
unsafe {
|
|
MmapOptions::new()
|
|
.map_mut(&file)
|
|
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))
|
|
}
|
|
}
|