Skip to content

Commit

Permalink
fix windows build
Browse files Browse the repository at this point in the history
  • Loading branch information
modelflat committed Jan 23, 2024
1 parent 1ef1661 commit e4a7006
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/mmvec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,11 @@ where

// On Windows it is required that file is not mapped before resizing.
// The safest option is to just drop and recreate the Data.
if cfg!(windows) {
#[cfg(windows)] {
drop(self.data.take());
self.data = Some(Data::from_file_unchecked_resized(self.path(), new_len)?);
} else {
}
#[cfg(not(windows))] {
self.data.as_mut().map_or(Ok(()), |d| d.resize(new_len))?;
}

Expand Down Expand Up @@ -417,9 +418,8 @@ fn resize_file_to_fit<T>(file: &File, header_size: u64, len: usize) -> io::Resul
unsafe fn mmap(file: &File, offset: u64, len: usize) -> io::Result<MmapMut> {
let mut opts = MmapOptions::new();
let mmap = opts.offset(offset).len(len).map_mut(file)?;
if cfg!(unix) {
mmap.advise(memmap2::Advice::Random).ok();
}
#[cfg(unix)]
mmap.advise(memmap2::Advice::Random).ok();
Ok(mmap)
}

Expand Down

0 comments on commit e4a7006

Please sign in to comment.