Minor changes & cleanup

This commit is contained in:
Luke Street 2024-12-01 22:44:02 -07:00
parent 1e44f23aba
commit 73eebfe90b
5 changed files with 1 additions and 80 deletions

26
Cargo.lock generated
View File

@ -73,21 +73,6 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf"
[[package]]
name = "bit-set"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08807e080ed7f9d5433fa9b275196cfc35414f66a0c79d864dc51a0d825231a3"
dependencies = [
"bit-vec",
]
[[package]]
name = "bit-vec"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7"
[[package]]
name = "bitflags"
version = "2.6.0"
@ -562,15 +547,6 @@ version = "2.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
[[package]]
name = "memmap2"
version = "0.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd3f7eed9d3848f8b98834af67102b720745c4ec028fcd0aa0239277e7de374f"
dependencies = [
"libc",
]
[[package]]
name = "mimalloc"
version = "0.1.43"
@ -602,7 +578,6 @@ dependencies = [
"adler",
"aes",
"base16ct",
"bit-set",
"bytes",
"bzip2",
"cbc",
@ -617,7 +592,6 @@ dependencies = [
"liblzma-sys",
"lru",
"md-5",
"memmap2",
"miniz_oxide",
"openssl",
"polonius-the-crab",

View File

@ -27,7 +27,6 @@ openssl-vendored = ["openssl", "openssl/vendored"]
adler = { version = "1.0", optional = true }
aes = "0.9.0-pre.2"
base16ct = "0.2"
bit-set = "0.8"
bytes = "1.8"
bzip2 = { version = "0.4", features = ["static"], optional = true }
cbc = "0.2.0-pre.2"
@ -42,7 +41,6 @@ liblzma = { version = "0.3", features = ["static"], optional = true }
liblzma-sys = { version = "0.3", features = ["static"], optional = true }
lru = "0.12"
md-5 = { workspace = true }
memmap2 = "0.9"
miniz_oxide = { version = "0.8", optional = true }
openssl = { version = "0.10", optional = true }
polonius-the-crab = "0.4"

View File

@ -1,51 +0,0 @@
use std::{io, path::Path, sync::Arc};
use memmap2::Mmap;
use crate::{util::impl_read_for_bufread, Result, ResultContext};
pub struct MappedFileReader {
inner: Arc<Mmap>,
pos: usize,
}
impl Clone for MappedFileReader {
fn clone(&self) -> Self { Self { inner: self.inner.clone(), pos: 0 } }
}
impl MappedFileReader {
#[expect(unused)]
pub fn new(path: &Path) -> Result<Self> {
let file = std::fs::File::open(path)
.with_context(|| format!("Failed to open file {}", path.display()))?;
let inner = unsafe { Mmap::map(&file) }
.with_context(|| format!("Failed to map file {}", path.display()))?;
Ok(Self { inner: Arc::new(inner), pos: 0 })
}
}
impl io::BufRead for MappedFileReader {
fn fill_buf(&mut self) -> io::Result<&[u8]> {
if self.pos < self.inner.len() {
Ok(&self.inner[self.pos..])
} else {
Ok(&[])
}
}
fn consume(&mut self, amt: usize) { self.pos = self.pos.saturating_add(amt); }
}
impl_read_for_bufread!(MappedFileReader);
impl io::Seek for MappedFileReader {
fn seek(&mut self, pos: io::SeekFrom) -> io::Result<u64> {
let pos = match pos {
io::SeekFrom::Start(pos) => pos,
io::SeekFrom::End(pos) => (self.inner.len() as u64).saturating_add_signed(pos),
io::SeekFrom::Current(off) => (self.pos as u64).saturating_add_signed(off),
};
self.pos = pos.try_into().map_err(|_| io::ErrorKind::UnexpectedEof)?;
Ok(pos)
}
}

View File

@ -5,7 +5,6 @@ pub(crate) mod ciso;
#[cfg(feature = "compress-zlib")]
pub(crate) mod gcz;
pub(crate) mod iso;
pub(crate) mod mapped;
pub(crate) mod nfs;
pub(crate) mod nkit;
pub(crate) mod split;

View File

@ -1517,6 +1517,7 @@ impl DiscWriterWIA {
let mut partitions = <[WIAPartition]>::new_box_zeroed_with_elems(num_partitions as usize)?;
let mut raw_data = <[WIARawData]>::new_box_zeroed_with_elems(num_raw_data as usize)?;
raw_data[0].raw_data_offset = (DISC_HEAD_SIZE as u64).into();
let mut raw_data_idx = 0;
let mut group_idx = 0;