memmap -> memmap2 (#183)

This commit is contained in:
CosmicHorror 2023-05-08 19:56:51 -06:00 committed by GitHub
parent 14307b9d09
commit f52e96e8ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 9 deletions

9
Cargo.lock generated
View file

@ -363,13 +363,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
[[package]]
name = "memmap"
version = "0.7.0"
name = "memmap2"
version = "0.5.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6585fd95e7bb50d6cc31e20d4cf9afb4e2ba16c5846fc76793f11218da9c475b"
checksum = "83faa42c0a078c393f6b29d5db232d8be22776a891f8f56e5284faee4a20b327"
dependencies = [
"libc",
"winapi",
]
[[package]]
@ -566,7 +565,7 @@ dependencies = [
"globwalk",
"ignore",
"man",
"memmap",
"memmap2",
"rayon",
"regex",
"structopt",

View file

@ -16,7 +16,7 @@ regex = "1.4.3"
structopt = "0.3.21"
rayon = "1.5.0"
unescape = "0.1.0"
memmap = "0.7.0"
memmap2 = "0.5.10"
tempfile = "3.2.0"
thiserror = "1.0.24"
globwalk = "0.8.1"

View file

@ -77,7 +77,7 @@ impl App {
return Ok(());
}
let file =
unsafe { memmap::Mmap::map(&File::open(path)?)? };
unsafe { memmap2::Mmap::map(&File::open(path)?)? };
if self.replacer.has_matches(&file) {
if print_path {
writeln!(

View file

@ -124,7 +124,7 @@ impl Replacer {
}
pub(crate) fn replace_file(&self, path: &Path) -> Result<()> {
use memmap::{Mmap, MmapMut};
use memmap2::{Mmap, MmapMut};
use std::ops::DerefMut;
if let Err(_) = Self::check_not_empty(File::open(path)?) {
@ -145,7 +145,7 @@ impl Replacer {
file.set_permissions(meta.permissions())?;
if !replaced.is_empty() {
let mut mmap_target = unsafe { MmapMut::map_mut(&file)? };
let mut mmap_target = unsafe { MmapMut::map_mut(file)? };
mmap_target.deref_mut().write_all(&replaced)?;
mmap_target.flush_async()?;
}