mirror of
https://github.com/encounter/nod-rs.git
synced 2025-06-10 16:43:37 +00:00
Migrate to Rust edition 2024
This commit is contained in:
parent
fb3542f445
commit
d6969045be
2
.github/workflows/build.yaml
vendored
2
.github/workflows/build.yaml
vendored
@ -19,7 +19,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
toolchain: [ stable, 1.81.0, nightly ]
|
||||
toolchain: [ stable, 1.85.0, nightly ]
|
||||
fail-fast: false
|
||||
env:
|
||||
RUSTFLAGS: -D warnings
|
||||
|
@ -1,6 +1,6 @@
|
||||
[workspace]
|
||||
members = ["nod", "nodtool"]
|
||||
resolver = "2"
|
||||
resolver = "3"
|
||||
|
||||
[profile.release]
|
||||
debug = 1
|
||||
@ -13,8 +13,8 @@ codegen-units = 1
|
||||
|
||||
[workspace.package]
|
||||
version = "2.0.0-alpha.1"
|
||||
edition = "2021"
|
||||
rust-version = "1.81"
|
||||
edition = "2024"
|
||||
rust-version = "1.85"
|
||||
authors = ["Luke Street <luke@street.dev>"]
|
||||
license = "MIT OR Apache-2.0"
|
||||
repository = "https://github.com/encounter/nod"
|
||||
|
@ -6,7 +6,7 @@
|
||||
[crates.io]: https://crates.io/crates/nod
|
||||
[Api Rustdoc]: https://img.shields.io/badge/api-rustdoc-blue.svg
|
||||
[rustdoc]: https://docs.rs/nod
|
||||
[Rust Version]: https://img.shields.io/badge/rust-1.81+-blue.svg?maxAge=3600
|
||||
[Rust Version]: https://img.shields.io/badge/rust-1.85+-blue.svg?maxAge=3600
|
||||
|
||||
Library for reading and writing Nintendo Optical Disc (GameCube and Wii) images.
|
||||
|
||||
|
@ -9,14 +9,14 @@ use tracing::debug;
|
||||
use zerocopy::{FromZeros, IntoBytes};
|
||||
|
||||
use crate::{
|
||||
Error, Result, ResultContext,
|
||||
disc::{
|
||||
fst::{Fst, FstBuilder},
|
||||
BootHeader, DiscHeader, BI2_SIZE, BOOT_SIZE, GCN_MAGIC, MINI_DVD_SIZE, SECTOR_SIZE,
|
||||
BI2_SIZE, BOOT_SIZE, BootHeader, DiscHeader, GCN_MAGIC, MINI_DVD_SIZE, SECTOR_SIZE,
|
||||
WII_MAGIC,
|
||||
fst::{Fst, FstBuilder},
|
||||
},
|
||||
read::DiscStream,
|
||||
util::{array_ref, array_ref_mut, lfg::LaggedFibonacci, Align},
|
||||
Error, Result, ResultContext,
|
||||
util::{Align, array_ref, array_ref_mut, lfg::LaggedFibonacci},
|
||||
};
|
||||
|
||||
pub trait FileCallback: Clone + Send + Sync {
|
||||
|
@ -5,12 +5,12 @@ use std::{borrow::Cow, fmt, str::FromStr, sync::Arc};
|
||||
use zerocopy::FromBytes;
|
||||
|
||||
use crate::{
|
||||
Error, Result,
|
||||
disc::{
|
||||
fst::Fst, wii::WiiPartitionHeader, BootHeader, DebugHeader, DiscHeader, BB2_OFFSET,
|
||||
BOOT_SIZE, SECTOR_SIZE,
|
||||
BB2_OFFSET, BOOT_SIZE, BootHeader, DebugHeader, DiscHeader, SECTOR_SIZE, fst::Fst,
|
||||
wii::WiiPartitionHeader,
|
||||
},
|
||||
util::array_ref,
|
||||
Error, Result,
|
||||
};
|
||||
|
||||
/// SHA-1 hash bytes
|
||||
|
@ -7,11 +7,11 @@ use std::{
|
||||
use zerocopy::FromZeros;
|
||||
|
||||
use crate::{
|
||||
Result,
|
||||
common::KeyBytes,
|
||||
disc::{wii::SECTOR_DATA_SIZE, DiscHeader, SECTOR_SIZE},
|
||||
disc::{DiscHeader, SECTOR_SIZE, wii::SECTOR_DATA_SIZE},
|
||||
io::block::{Block, BlockReader},
|
||||
util::impl_read_for_bufread,
|
||||
Result,
|
||||
};
|
||||
|
||||
#[derive(Clone)]
|
||||
|
@ -4,11 +4,11 @@ use std::{borrow::Cow, ffi::CStr, mem::size_of};
|
||||
|
||||
use encoding_rs::SHIFT_JIS;
|
||||
use itertools::Itertools;
|
||||
use zerocopy::{big_endian::*, FromBytes, FromZeros, Immutable, IntoBytes, KnownLayout};
|
||||
use zerocopy::{FromBytes, FromZeros, Immutable, IntoBytes, KnownLayout, big_endian::*};
|
||||
|
||||
use crate::{
|
||||
util::{array_ref, static_assert},
|
||||
Error, Result,
|
||||
util::{array_ref, static_assert},
|
||||
};
|
||||
|
||||
/// File system node kind.
|
||||
@ -39,13 +39,14 @@ impl Node {
|
||||
/// Create a new node.
|
||||
#[inline]
|
||||
pub fn new(kind: NodeKind, name_offset: u32, offset: u64, length: u32, is_wii: bool) -> Self {
|
||||
let name_offset_bytes = name_offset.to_be_bytes();
|
||||
Self {
|
||||
kind: match kind {
|
||||
NodeKind::File => 0,
|
||||
NodeKind::Directory => 1,
|
||||
NodeKind::Invalid => u8::MAX,
|
||||
},
|
||||
name_offset: *array_ref![name_offset.to_be_bytes(), 1, 3],
|
||||
name_offset: *array_ref![name_offset_bytes, 1, 3],
|
||||
offset: U32::new(match kind {
|
||||
NodeKind::File if is_wii => (offset / 4) as u32,
|
||||
_ => offset as u32,
|
||||
@ -91,7 +92,8 @@ impl Node {
|
||||
/// Set the name offset of the node.
|
||||
#[inline]
|
||||
pub fn set_name_offset(&mut self, name_offset: u32) {
|
||||
self.name_offset = *array_ref![name_offset.to_be_bytes(), 1, 3];
|
||||
let name_offset_bytes = name_offset.to_be_bytes();
|
||||
self.name_offset = *array_ref![name_offset_bytes, 1, 3];
|
||||
}
|
||||
|
||||
/// For files, this is the partition offset of the file data. (Wii: >> 2)
|
||||
|
@ -8,10 +8,11 @@ use std::{
|
||||
use zerocopy::{FromBytes, FromZeros, IntoBytes};
|
||||
|
||||
use crate::{
|
||||
Result, ResultContext,
|
||||
disc::{
|
||||
preloader::{fetch_sector_group, Preloader, SectorGroup, SectorGroupRequest},
|
||||
ApploaderHeader, BootHeader, DolHeader, BB2_OFFSET, BI2_SIZE, BOOT_SIZE, SECTOR_GROUP_SIZE,
|
||||
ApploaderHeader, BB2_OFFSET, BI2_SIZE, BOOT_SIZE, BootHeader, DolHeader, SECTOR_GROUP_SIZE,
|
||||
SECTOR_SIZE,
|
||||
preloader::{Preloader, SectorGroup, SectorGroupRequest, fetch_sector_group},
|
||||
},
|
||||
io::block::BlockReader,
|
||||
read::{DiscStream, PartitionEncryption, PartitionMeta, PartitionReader},
|
||||
@ -19,7 +20,6 @@ use crate::{
|
||||
impl_read_for_bufread,
|
||||
read::{read_arc, read_arc_slice, read_from},
|
||||
},
|
||||
Result, ResultContext,
|
||||
};
|
||||
|
||||
pub struct PartitionReaderGC {
|
||||
|
@ -4,8 +4,8 @@ use zerocopy::{FromZeros, IntoBytes};
|
||||
use crate::{
|
||||
common::HashBytes,
|
||||
disc::{
|
||||
wii::{HASHES_SIZE, SECTOR_DATA_SIZE},
|
||||
SECTOR_GROUP_SIZE, SECTOR_SIZE,
|
||||
wii::{HASHES_SIZE, SECTOR_DATA_SIZE},
|
||||
},
|
||||
util::{array_ref, array_ref_mut, digest::sha1_hash},
|
||||
};
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
use std::{ffi::CStr, str::from_utf8};
|
||||
|
||||
use zerocopy::{big_endian::*, FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout, big_endian::*};
|
||||
|
||||
use crate::{common::MagicBytes, util::static_assert};
|
||||
|
||||
@ -166,11 +166,7 @@ impl BootHeader {
|
||||
/// Offset within the partition to the main DOL.
|
||||
#[inline]
|
||||
pub fn dol_offset(&self, is_wii: bool) -> u64 {
|
||||
if is_wii {
|
||||
self.dol_offset.get() as u64 * 4
|
||||
} else {
|
||||
self.dol_offset.get() as u64
|
||||
}
|
||||
if is_wii { self.dol_offset.get() as u64 * 4 } else { self.dol_offset.get() as u64 }
|
||||
}
|
||||
|
||||
/// Set the offset within the partition to the main DOL.
|
||||
@ -186,11 +182,7 @@ impl BootHeader {
|
||||
/// Offset within the partition to the file system table (FST).
|
||||
#[inline]
|
||||
pub fn fst_offset(&self, is_wii: bool) -> u64 {
|
||||
if is_wii {
|
||||
self.fst_offset.get() as u64 * 4
|
||||
} else {
|
||||
self.fst_offset.get() as u64
|
||||
}
|
||||
if is_wii { self.fst_offset.get() as u64 * 4 } else { self.fst_offset.get() as u64 }
|
||||
}
|
||||
|
||||
/// Set the offset within the partition to the file system table (FST).
|
||||
@ -206,11 +198,7 @@ impl BootHeader {
|
||||
/// Size of the file system table (FST).
|
||||
#[inline]
|
||||
pub fn fst_size(&self, is_wii: bool) -> u64 {
|
||||
if is_wii {
|
||||
self.fst_size.get() as u64 * 4
|
||||
} else {
|
||||
self.fst_size.get() as u64
|
||||
}
|
||||
if is_wii { self.fst_size.get() as u64 * 4 } else { self.fst_size.get() as u64 }
|
||||
}
|
||||
|
||||
/// Set the size of the file system table (FST).
|
||||
@ -226,11 +214,7 @@ impl BootHeader {
|
||||
/// Maximum size of the file system table (FST) across multi-disc games.
|
||||
#[inline]
|
||||
pub fn fst_max_size(&self, is_wii: bool) -> u64 {
|
||||
if is_wii {
|
||||
self.fst_max_size.get() as u64 * 4
|
||||
} else {
|
||||
self.fst_max_size.get() as u64
|
||||
}
|
||||
if is_wii { self.fst_max_size.get() as u64 * 4 } else { self.fst_max_size.get() as u64 }
|
||||
}
|
||||
|
||||
/// Set the maximum size of the file system table (FST) across multi-disc games.
|
||||
|
@ -13,16 +13,17 @@ use crossbeam_channel::{Receiver, Sender};
|
||||
use crossbeam_utils::sync::WaitGroup;
|
||||
use lru::LruCache;
|
||||
use polonius_the_crab::{polonius, polonius_return};
|
||||
use simple_moving_average::{SingleSumSMA, SMA};
|
||||
use tracing::{debug, error, instrument, span, Level};
|
||||
use simple_moving_average::{SMA, SingleSumSMA};
|
||||
use tracing::{Level, debug, error, instrument, span};
|
||||
use zerocopy::FromZeros;
|
||||
|
||||
use crate::{
|
||||
IoResultContext,
|
||||
common::PartitionInfo,
|
||||
disc::{
|
||||
hashes::{hash_sector_group, GroupHashes},
|
||||
wii::HASHES_SIZE,
|
||||
DiscHeader, SECTOR_GROUP_SIZE, SECTOR_SIZE,
|
||||
hashes::{GroupHashes, hash_sector_group},
|
||||
wii::HASHES_SIZE,
|
||||
},
|
||||
io::{
|
||||
block::{Block, BlockKind, BlockReader},
|
||||
@ -33,7 +34,6 @@ use crate::{
|
||||
aes::{decrypt_sector, encrypt_sector},
|
||||
array_ref_mut,
|
||||
},
|
||||
IoResultContext,
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
|
@ -10,20 +10,21 @@ use tracing::warn;
|
||||
use zerocopy::{FromBytes, IntoBytes};
|
||||
|
||||
use crate::{
|
||||
Error, Result, ResultContext,
|
||||
common::{PartitionInfo, PartitionKind},
|
||||
disc::{
|
||||
BB2_OFFSET, BOOT_SIZE, BootHeader, DL_DVD_SIZE, DiscHeader, MINI_DVD_SIZE,
|
||||
SECTOR_GROUP_SIZE, SECTOR_SIZE, SL_DVD_SIZE,
|
||||
direct::{DirectDiscReader, DirectDiscReaderMode},
|
||||
fst::{Fst, NodeKind},
|
||||
gcn::{read_fst, PartitionReaderGC},
|
||||
gcn::{PartitionReaderGC, read_fst},
|
||||
preloader::{
|
||||
fetch_sector_group, Preloader, SectorGroup, SectorGroupLoader, SectorGroupRequest,
|
||||
Preloader, SectorGroup, SectorGroupLoader, SectorGroupRequest, fetch_sector_group,
|
||||
},
|
||||
wii::{
|
||||
PartitionReaderWii, WiiPartEntry, WiiPartGroup, WiiPartitionHeader, REGION_OFFSET,
|
||||
REGION_SIZE, WII_PART_GROUP_OFF,
|
||||
PartitionReaderWii, REGION_OFFSET, REGION_SIZE, WII_PART_GROUP_OFF, WiiPartEntry,
|
||||
WiiPartGroup, WiiPartitionHeader,
|
||||
},
|
||||
BootHeader, DiscHeader, BB2_OFFSET, BOOT_SIZE, DL_DVD_SIZE, MINI_DVD_SIZE,
|
||||
SECTOR_GROUP_SIZE, SECTOR_SIZE, SL_DVD_SIZE,
|
||||
},
|
||||
io::block::BlockReader,
|
||||
read::{DiscMeta, DiscOptions, PartitionEncryption, PartitionOptions, PartitionReader},
|
||||
@ -31,7 +32,6 @@ use crate::{
|
||||
array_ref, impl_read_for_bufread,
|
||||
read::{read_arc, read_from, read_vec},
|
||||
},
|
||||
Error, Result, ResultContext,
|
||||
};
|
||||
|
||||
pub struct DiscReader {
|
||||
|
@ -8,14 +8,15 @@ use std::{
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
use zerocopy::{big_endian::*, FromBytes, Immutable, IntoBytes, KnownLayout};
|
||||
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout, big_endian::*};
|
||||
|
||||
use crate::{
|
||||
Error, Result, ResultContext,
|
||||
common::{HashBytes, KeyBytes, PartitionInfo},
|
||||
disc::{
|
||||
gcn::{read_part_meta, PartitionReaderGC},
|
||||
preloader::{fetch_sector_group, Preloader, SectorGroup, SectorGroupRequest},
|
||||
SECTOR_GROUP_SIZE, SECTOR_SIZE,
|
||||
gcn::{PartitionReaderGC, read_part_meta},
|
||||
preloader::{Preloader, SectorGroup, SectorGroupRequest, fetch_sector_group},
|
||||
},
|
||||
io::block::BlockReader,
|
||||
read::{PartitionEncryption, PartitionMeta, PartitionOptions, PartitionReader},
|
||||
@ -27,7 +28,6 @@ use crate::{
|
||||
read::{read_arc, read_arc_slice},
|
||||
static_assert,
|
||||
},
|
||||
Error, Result, ResultContext,
|
||||
};
|
||||
|
||||
/// Size in bytes of the hashes block in a Wii disc sector
|
||||
|
@ -8,15 +8,15 @@ use dyn_clone::DynClone;
|
||||
use rayon::prelude::*;
|
||||
|
||||
use crate::{
|
||||
Error, Result, ResultContext,
|
||||
common::PartitionInfo,
|
||||
disc::{
|
||||
SECTOR_SIZE,
|
||||
reader::DiscReader,
|
||||
wii::{HASHES_SIZE, SECTOR_DATA_SIZE},
|
||||
SECTOR_SIZE,
|
||||
},
|
||||
util::{aes::decrypt_sector_b2b, array_ref, array_ref_mut, lfg::LaggedFibonacci},
|
||||
write::{DiscFinalization, DiscWriterWeight, ProcessOptions},
|
||||
Error, Result, ResultContext,
|
||||
};
|
||||
|
||||
/// A callback for writing disc data.
|
||||
|
@ -3,10 +3,11 @@ use std::{fs, io, io::Read, path::Path};
|
||||
use dyn_clone::DynClone;
|
||||
|
||||
use crate::{
|
||||
Error, Result, ResultContext,
|
||||
common::{Format, KeyBytes, MagicBytes, PartitionInfo},
|
||||
disc::{
|
||||
wii::{HASHES_SIZE, SECTOR_DATA_SIZE},
|
||||
DiscHeader, GCN_MAGIC, SECTOR_SIZE, WII_MAGIC,
|
||||
wii::{HASHES_SIZE, SECTOR_DATA_SIZE},
|
||||
},
|
||||
io::{
|
||||
split::SplitFileReader,
|
||||
@ -14,7 +15,6 @@ use crate::{
|
||||
},
|
||||
read::{DiscMeta, DiscStream},
|
||||
util::{aes::decrypt_sector, array_ref, array_ref_mut, lfg::LaggedFibonacci, read::read_from},
|
||||
Error, Result, ResultContext,
|
||||
};
|
||||
|
||||
/// Block reader trait for reading disc images.
|
||||
@ -45,7 +45,7 @@ pub fn new(mut stream: Box<dyn DiscStream>) -> Result<Box<dyn BlockReader>> {
|
||||
return Err(Error::DiscFormat("GCZ support is disabled".to_string()));
|
||||
}
|
||||
Some(Format::Nfs) => {
|
||||
return Err(Error::DiscFormat("NFS requires a filesystem path".to_string()))
|
||||
return Err(Error::DiscFormat("NFS requires a filesystem path".to_string()));
|
||||
}
|
||||
Some(Format::Wbfs) => crate::io::wbfs::BlockReaderWBFS::new(stream)?,
|
||||
Some(Format::Wia | Format::Rvz) => crate::io::wia::BlockReaderWIA::new(stream)?,
|
||||
|
@ -6,17 +6,18 @@ use std::{
|
||||
};
|
||||
|
||||
use bytes::{BufMut, Bytes, BytesMut};
|
||||
use zerocopy::{little_endian::*, FromBytes, FromZeros, Immutable, IntoBytes, KnownLayout};
|
||||
use zerocopy::{FromBytes, FromZeros, Immutable, IntoBytes, KnownLayout, little_endian::*};
|
||||
|
||||
use crate::{
|
||||
Error, Result, ResultContext,
|
||||
common::{Compression, Format, MagicBytes},
|
||||
disc::{
|
||||
SECTOR_SIZE,
|
||||
reader::DiscReader,
|
||||
writer::{
|
||||
check_block, par_process, read_block, BlockProcessor, BlockResult, CheckBlockResult,
|
||||
DataCallback, DiscWriter,
|
||||
BlockProcessor, BlockResult, CheckBlockResult, DataCallback, DiscWriter, check_block,
|
||||
par_process, read_block,
|
||||
},
|
||||
SECTOR_SIZE,
|
||||
},
|
||||
io::{
|
||||
block::{Block, BlockKind, BlockReader, CISO_MAGIC},
|
||||
@ -31,7 +32,6 @@ use crate::{
|
||||
static_assert,
|
||||
},
|
||||
write::{DiscFinalization, DiscWriterWeight, FormatOptions, ProcessOptions},
|
||||
Error, Result, ResultContext,
|
||||
};
|
||||
|
||||
pub const CISO_MAP_SIZE: usize = SECTOR_SIZE - 8;
|
||||
|
@ -7,14 +7,15 @@ use std::{
|
||||
|
||||
use adler::adler32_slice;
|
||||
use bytes::{BufMut, Bytes, BytesMut};
|
||||
use zerocopy::{little_endian::*, FromBytes, FromZeros, Immutable, IntoBytes, KnownLayout};
|
||||
use zerocopy::{FromBytes, FromZeros, Immutable, IntoBytes, KnownLayout, little_endian::*};
|
||||
|
||||
use crate::{
|
||||
Error, Result, ResultContext,
|
||||
common::{Compression, Format, MagicBytes},
|
||||
disc::{
|
||||
reader::DiscReader,
|
||||
writer::{par_process, read_block, BlockProcessor, BlockResult, DataCallback, DiscWriter},
|
||||
SECTOR_SIZE,
|
||||
reader::DiscReader,
|
||||
writer::{BlockProcessor, BlockResult, DataCallback, DiscWriter, par_process, read_block},
|
||||
},
|
||||
io::block::{Block, BlockKind, BlockReader, GCZ_MAGIC},
|
||||
read::{DiscMeta, DiscStream},
|
||||
@ -25,7 +26,6 @@ use crate::{
|
||||
static_assert,
|
||||
},
|
||||
write::{DiscFinalization, DiscWriterWeight, FormatOptions, ProcessOptions},
|
||||
Error, Result, ResultContext,
|
||||
};
|
||||
|
||||
/// GCZ header (little endian)
|
||||
|
@ -4,17 +4,17 @@ use std::{
|
||||
};
|
||||
|
||||
use crate::{
|
||||
Result, ResultContext,
|
||||
common::Format,
|
||||
disc::{
|
||||
SECTOR_SIZE,
|
||||
reader::DiscReader,
|
||||
writer::{DataCallback, DiscWriter},
|
||||
SECTOR_SIZE,
|
||||
},
|
||||
io::block::{Block, BlockKind, BlockReader},
|
||||
read::{DiscMeta, DiscStream},
|
||||
util::digest::DigestManager,
|
||||
write::{DiscFinalization, DiscWriterWeight, ProcessOptions},
|
||||
Result, ResultContext,
|
||||
};
|
||||
|
||||
#[derive(Clone)]
|
||||
|
@ -7,9 +7,10 @@ use std::{
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
use zerocopy::{big_endian::U32, FromBytes, FromZeros, Immutable, IntoBytes, KnownLayout};
|
||||
use zerocopy::{FromBytes, FromZeros, Immutable, IntoBytes, KnownLayout, big_endian::U32};
|
||||
|
||||
use crate::{
|
||||
Error, Result, ResultContext,
|
||||
common::{Format, KeyBytes, MagicBytes},
|
||||
disc::SECTOR_SIZE,
|
||||
io::{
|
||||
@ -18,7 +19,6 @@ use crate::{
|
||||
},
|
||||
read::DiscMeta,
|
||||
util::{aes::aes_cbc_decrypt, array_ref_mut, read::read_arc, static_assert},
|
||||
Error, Result, ResultContext,
|
||||
};
|
||||
|
||||
pub const NFS_END_MAGIC: MagicBytes = *b"SGGE";
|
||||
|
@ -5,27 +5,27 @@ use std::{
|
||||
};
|
||||
|
||||
use bytes::{BufMut, Bytes, BytesMut};
|
||||
use zerocopy::{big_endian::U32, FromBytes, FromZeros, Immutable, IntoBytes, KnownLayout};
|
||||
use zerocopy::{FromBytes, FromZeros, Immutable, IntoBytes, KnownLayout, big_endian::U32};
|
||||
|
||||
use crate::{
|
||||
build::gc::{insert_junk_data, FileCallback, GCPartitionStream, WriteInfo, WriteKind},
|
||||
Error, Result, ResultContext,
|
||||
build::gc::{FileCallback, GCPartitionStream, WriteInfo, WriteKind, insert_junk_data},
|
||||
common::{Compression, Format, MagicBytes, PartitionKind},
|
||||
disc::{
|
||||
BB2_OFFSET, BootHeader, DiscHeader, SECTOR_SIZE,
|
||||
fst::Fst,
|
||||
gcn::{read_dol, read_fst},
|
||||
reader::DiscReader,
|
||||
writer::{DataCallback, DiscWriter},
|
||||
BootHeader, DiscHeader, BB2_OFFSET, SECTOR_SIZE,
|
||||
},
|
||||
io::block::{Block, BlockKind, BlockReader, TGC_MAGIC},
|
||||
read::{DiscMeta, DiscStream, PartitionOptions, PartitionReader},
|
||||
util::{
|
||||
array_ref,
|
||||
Align, array_ref,
|
||||
read::{read_arc, read_arc_slice, read_from, read_with_zero_fill},
|
||||
static_assert, Align,
|
||||
static_assert,
|
||||
},
|
||||
write::{DiscFinalization, DiscWriterWeight, FormatOptions, ProcessOptions},
|
||||
Error, Result, ResultContext,
|
||||
};
|
||||
|
||||
/// TGC header (big endian)
|
||||
|
@ -6,17 +6,18 @@ use std::{
|
||||
};
|
||||
|
||||
use bytes::{BufMut, Bytes, BytesMut};
|
||||
use zerocopy::{big_endian::*, FromBytes, FromZeros, Immutable, IntoBytes, KnownLayout};
|
||||
use zerocopy::{FromBytes, FromZeros, Immutable, IntoBytes, KnownLayout, big_endian::*};
|
||||
|
||||
use crate::{
|
||||
Error, Result, ResultContext,
|
||||
common::{Compression, Format, MagicBytes},
|
||||
disc::{
|
||||
SECTOR_SIZE,
|
||||
reader::DiscReader,
|
||||
writer::{
|
||||
check_block, par_process, read_block, BlockProcessor, BlockResult, CheckBlockResult,
|
||||
DataCallback, DiscWriter,
|
||||
BlockProcessor, BlockResult, CheckBlockResult, DataCallback, DiscWriter, check_block,
|
||||
par_process, read_block,
|
||||
},
|
||||
SECTOR_SIZE,
|
||||
},
|
||||
io::{
|
||||
block::{Block, BlockKind, BlockReader, WBFS_MAGIC},
|
||||
@ -30,7 +31,6 @@ use crate::{
|
||||
read::{read_arc_slice, read_box_slice, read_from},
|
||||
},
|
||||
write::{DiscFinalization, DiscWriterWeight, FormatOptions, ProcessOptions},
|
||||
Error, Result, ResultContext,
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, FromBytes, IntoBytes, Immutable, KnownLayout)]
|
||||
|
@ -1,6 +1,6 @@
|
||||
use std::{
|
||||
borrow::Cow,
|
||||
collections::{hash_map::Entry, BTreeSet, HashMap},
|
||||
collections::{BTreeSet, HashMap, hash_map::Entry},
|
||||
io,
|
||||
io::{Read, Seek, SeekFrom},
|
||||
mem::size_of,
|
||||
@ -10,16 +10,17 @@ use std::{
|
||||
|
||||
use bytes::{Buf, BufMut, Bytes, BytesMut};
|
||||
use tracing::{debug, instrument, warn};
|
||||
use zerocopy::{big_endian::*, FromBytes, FromZeros, Immutable, IntoBytes, KnownLayout};
|
||||
use zerocopy::{FromBytes, FromZeros, Immutable, IntoBytes, KnownLayout, big_endian::*};
|
||||
|
||||
use crate::{
|
||||
Error, IoResultContext, Result, ResultContext,
|
||||
common::{Compression, Format, HashBytes, KeyBytes, MagicBytes},
|
||||
disc::{
|
||||
BootHeader, DiscHeader, SECTOR_SIZE,
|
||||
fst::Fst,
|
||||
reader::DiscReader,
|
||||
wii::{HASHES_SIZE, SECTOR_DATA_SIZE},
|
||||
writer::{par_process, read_block, BlockProcessor, BlockResult, DataCallback, DiscWriter},
|
||||
BootHeader, DiscHeader, SECTOR_SIZE,
|
||||
writer::{BlockProcessor, BlockResult, DataCallback, DiscWriter, par_process, read_block},
|
||||
},
|
||||
io::{
|
||||
block::{Block, BlockKind, BlockReader, RVZ_MAGIC, WIA_MAGIC},
|
||||
@ -27,16 +28,16 @@ use crate::{
|
||||
},
|
||||
read::{DiscMeta, DiscStream},
|
||||
util::{
|
||||
Align,
|
||||
aes::decrypt_sector_data_b2b,
|
||||
array_ref, array_ref_mut,
|
||||
compress::{Compressor, DecompressionKind, Decompressor},
|
||||
digest::{sha1_hash, xxh64_hash, DigestManager},
|
||||
digest::{DigestManager, sha1_hash, xxh64_hash},
|
||||
lfg::{LaggedFibonacci, SEED_SIZE, SEED_SIZE_BYTES},
|
||||
read::{read_arc_slice, read_from, read_vec},
|
||||
static_assert, Align,
|
||||
static_assert,
|
||||
},
|
||||
write::{DiscFinalization, DiscWriterWeight, FormatOptions, ProcessOptions},
|
||||
Error, IoResultContext, Result, ResultContext,
|
||||
};
|
||||
|
||||
const WIA_VERSION: u32 = 0x01000000;
|
||||
@ -1492,7 +1493,7 @@ impl DiscWriterWIA {
|
||||
return Err(Error::Other(format!(
|
||||
"Unsupported compression for WIA/RVZ: {}",
|
||||
options.compression
|
||||
)))
|
||||
)));
|
||||
}
|
||||
};
|
||||
let compr_data = compr_data(options.compression).context("Building compression data")?;
|
||||
|
@ -9,17 +9,17 @@ use dyn_clone::DynClone;
|
||||
use zerocopy::FromBytes;
|
||||
|
||||
use crate::{
|
||||
Result,
|
||||
common::{Compression, Format, PartitionInfo, PartitionKind},
|
||||
disc,
|
||||
disc::{
|
||||
ApploaderHeader, BB2_OFFSET, BI2_SIZE, BOOT_SIZE, BootHeader, DebugHeader, DiscHeader,
|
||||
DolHeader,
|
||||
fst::{Fst, Node},
|
||||
wii::{ContentMetadata, Ticket, TmdHeader, H3_TABLE_SIZE, REGION_SIZE},
|
||||
ApploaderHeader, BootHeader, DebugHeader, DiscHeader, DolHeader, BB2_OFFSET, BI2_SIZE,
|
||||
BOOT_SIZE,
|
||||
wii::{ContentMetadata, H3_TABLE_SIZE, REGION_SIZE, Ticket, TmdHeader},
|
||||
},
|
||||
io::block,
|
||||
util::{array_ref, WindowedReader},
|
||||
Result,
|
||||
util::{WindowedReader, array_ref},
|
||||
};
|
||||
|
||||
/// Wii partition encryption mode.
|
||||
|
@ -3,8 +3,8 @@ use tracing::instrument;
|
||||
use crate::{
|
||||
common::KeyBytes,
|
||||
disc::{
|
||||
wii::{HASHES_SIZE, SECTOR_DATA_SIZE},
|
||||
SECTOR_SIZE,
|
||||
wii::{HASHES_SIZE, SECTOR_DATA_SIZE},
|
||||
},
|
||||
util::array_ref,
|
||||
};
|
||||
@ -32,7 +32,7 @@ pub fn aes_cbc_encrypt(key: &KeyBytes, iv: &KeyBytes, data: &mut [u8]) {
|
||||
assert_eq!(data.len() % 16, 0);
|
||||
#[cfg(not(feature = "openssl"))]
|
||||
{
|
||||
use aes::cipher::{block_padding::NoPadding, BlockModeEncrypt, KeyIvInit};
|
||||
use aes::cipher::{BlockModeEncrypt, KeyIvInit, block_padding::NoPadding};
|
||||
<cbc::Encryptor<aes::Aes128>>::new(key.into(), iv.into())
|
||||
.encrypt_padded::<NoPadding>(data, data.len())
|
||||
.unwrap();
|
||||
@ -57,7 +57,7 @@ pub fn aes_cbc_decrypt(key: &KeyBytes, iv: &KeyBytes, data: &mut [u8]) {
|
||||
assert_eq!(data.len() % 16, 0);
|
||||
#[cfg(not(feature = "openssl"))]
|
||||
{
|
||||
use aes::cipher::{block_padding::NoPadding, BlockModeDecrypt, KeyIvInit};
|
||||
use aes::cipher::{BlockModeDecrypt, KeyIvInit, block_padding::NoPadding};
|
||||
<cbc::Decryptor<aes::Aes128>>::new(key.into(), iv.into())
|
||||
.decrypt_padded::<NoPadding>(data)
|
||||
.unwrap();
|
||||
@ -83,7 +83,7 @@ pub fn aes_cbc_decrypt_b2b(key: &KeyBytes, iv: &KeyBytes, data: &[u8], out: &mut
|
||||
assert_eq!(data.len(), out.len());
|
||||
#[cfg(not(feature = "openssl"))]
|
||||
{
|
||||
use aes::cipher::{block_padding::NoPadding, BlockModeDecrypt, KeyIvInit};
|
||||
use aes::cipher::{BlockModeDecrypt, KeyIvInit, block_padding::NoPadding};
|
||||
<cbc::Decryptor<aes::Aes128>>::new(key.into(), iv.into())
|
||||
.decrypt_padded_b2b::<NoPadding>(data, out)
|
||||
.unwrap();
|
||||
|
@ -3,9 +3,9 @@ use std::{io, io::Read};
|
||||
use tracing::instrument;
|
||||
|
||||
use crate::{
|
||||
Error, Result,
|
||||
common::Compression,
|
||||
io::wia::{WIACompression, WIADisc},
|
||||
Error, Result,
|
||||
};
|
||||
|
||||
pub struct Decompressor {
|
||||
|
@ -7,7 +7,7 @@ use std::{
|
||||
|
||||
use bytes::Buf;
|
||||
use tracing::instrument;
|
||||
use zerocopy::{transmute_ref, IntoBytes};
|
||||
use zerocopy::{IntoBytes, transmute_ref};
|
||||
|
||||
use crate::{disc::SECTOR_SIZE, util::array_ref_mut};
|
||||
|
||||
|
@ -3,10 +3,10 @@
|
||||
use bytes::Bytes;
|
||||
|
||||
use crate::{
|
||||
Error, Result,
|
||||
common::{Compression, Format},
|
||||
disc,
|
||||
read::DiscReader,
|
||||
Error, Result,
|
||||
};
|
||||
|
||||
/// Options for writing a disc image.
|
||||
|
@ -4,7 +4,7 @@
|
||||
//! For now, this only adds a --version/-V option which causes early-exit.
|
||||
use std::ffi::OsStr;
|
||||
|
||||
use argp::{parser::ParseGlobalOptions, EarlyExit, FromArgs, TopLevelCommand};
|
||||
use argp::{EarlyExit, FromArgs, TopLevelCommand, parser::ParseGlobalOptions};
|
||||
|
||||
struct ArgsOrVersion<T>(T)
|
||||
where T: FromArgs;
|
||||
|
@ -47,7 +47,9 @@ pub fn run(args: Args) -> nod::Result<()> {
|
||||
(false, true) => PartitionEncryption::ForceEncrypted,
|
||||
(false, false) => PartitionEncryption::Original,
|
||||
(true, true) => {
|
||||
return Err(nod::Error::Other("Both --decrypt and --encrypt specified".to_string()))
|
||||
return Err(nod::Error::Other(
|
||||
"Both --decrypt and --encrypt specified".to_string(),
|
||||
));
|
||||
}
|
||||
},
|
||||
preloader_threads: 4,
|
||||
@ -70,7 +72,7 @@ pub fn run(args: Args) -> nod::Result<()> {
|
||||
return Err(nod::Error::Other(format!(
|
||||
"Unknown file extension: {}",
|
||||
path_display(&args.out)
|
||||
)))
|
||||
)));
|
||||
}
|
||||
None => Format::Iso,
|
||||
};
|
||||
|
@ -7,9 +7,9 @@ use std::{
|
||||
use argp::FromArgs;
|
||||
use indicatif::{ProgressBar, ProgressState, ProgressStyle};
|
||||
use nod::{
|
||||
Result, ResultContext,
|
||||
read::{DiscOptions, DiscReader, PartitionEncryption},
|
||||
write::{DiscWriter, FormatOptions, ProcessOptions},
|
||||
Result, ResultContext,
|
||||
};
|
||||
|
||||
use crate::util::{redump, redump::GameResult};
|
||||
|
@ -7,10 +7,10 @@ use std::{
|
||||
|
||||
use argp::FromArgs;
|
||||
use nod::{
|
||||
ResultContext,
|
||||
common::PartitionKind,
|
||||
disc::fst::{Fst, Node},
|
||||
read::{DiscOptions, DiscReader, PartitionMeta, PartitionOptions, PartitionReader},
|
||||
ResultContext,
|
||||
};
|
||||
use size::{Base, Size};
|
||||
use zerocopy::IntoBytes;
|
||||
|
@ -10,11 +10,12 @@ use std::{
|
||||
|
||||
use argp::FromArgs;
|
||||
use nod::{
|
||||
ResultContext,
|
||||
build::gc::{FileCallback, FileInfo, GCPartitionBuilder, PartitionOverrides},
|
||||
common::PartitionKind,
|
||||
disc::{
|
||||
fst::Fst, BootHeader, DiscHeader, BB2_OFFSET, BI2_SIZE, BOOT_SIZE, MINI_DVD_SIZE,
|
||||
SECTOR_SIZE,
|
||||
BB2_OFFSET, BI2_SIZE, BOOT_SIZE, BootHeader, DiscHeader, MINI_DVD_SIZE, SECTOR_SIZE,
|
||||
fst::Fst,
|
||||
},
|
||||
read::{
|
||||
DiscOptions, DiscReader, PartitionEncryption, PartitionMeta, PartitionOptions,
|
||||
@ -22,7 +23,6 @@ use nod::{
|
||||
},
|
||||
util::lfg::LaggedFibonacci,
|
||||
write::{DiscWriter, FormatOptions, ProcessOptions},
|
||||
ResultContext,
|
||||
};
|
||||
use tracing::{debug, error, info, warn};
|
||||
use zerocopy::{FromBytes, FromZeros};
|
||||
@ -188,7 +188,7 @@ pub fn run(args: Args) -> nod::Result<()> {
|
||||
}
|
||||
Err(e) => {
|
||||
return Err(e)
|
||||
.context(format!("Failed to get metadata for {}", file_path.display()))
|
||||
.context(format!("Failed to get metadata for {}", file_path.display()));
|
||||
}
|
||||
};
|
||||
if metadata.is_dir() {
|
||||
|
@ -1,6 +1,6 @@
|
||||
pub mod convert;
|
||||
pub mod dat;
|
||||
pub mod extract;
|
||||
pub mod gen;
|
||||
pub mod r#gen;
|
||||
pub mod info;
|
||||
pub mod verify;
|
||||
|
@ -41,7 +41,9 @@ pub fn run(args: Args) -> nod::Result<()> {
|
||||
(false, true) => PartitionEncryption::ForceEncrypted,
|
||||
(false, false) => PartitionEncryption::Original,
|
||||
(true, true) => {
|
||||
return Err(nod::Error::Other("Both --decrypt and --encrypt specified".to_string()))
|
||||
return Err(nod::Error::Other(
|
||||
"Both --decrypt and --encrypt specified".to_string(),
|
||||
));
|
||||
}
|
||||
},
|
||||
preloader_threads: 4.min(cpus),
|
||||
|
@ -13,7 +13,7 @@ pub enum SubCommand {
|
||||
Dat(cmd::dat::Args),
|
||||
Extract(cmd::extract::Args),
|
||||
// Gen(cmd::gen::Args),
|
||||
GenTest(cmd::gen::TestArgs),
|
||||
GenTest(cmd::r#gen::TestArgs),
|
||||
Info(cmd::info::Args),
|
||||
Verify(cmd::verify::Args),
|
||||
}
|
||||
@ -24,7 +24,7 @@ pub fn run(command: SubCommand) -> nod::Result<()> {
|
||||
SubCommand::Dat(c_args) => cmd::dat::run(c_args),
|
||||
SubCommand::Extract(c_args) => cmd::extract::run(c_args),
|
||||
// SubCommand::Gen(c_args) => cmd::gen::run(c_args),
|
||||
SubCommand::GenTest(c_args) => cmd::gen::run_test(c_args),
|
||||
SubCommand::GenTest(c_args) => cmd::r#gen::run_test(c_args),
|
||||
SubCommand::Info(c_args) => cmd::info::run(c_args),
|
||||
SubCommand::Verify(c_args) => cmd::verify::run(c_args),
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ use std::{env, error::Error, ffi::OsStr, fmt, path::PathBuf, str::FromStr};
|
||||
|
||||
use argp::{FromArgValue, FromArgs};
|
||||
use enable_ansi_support::enable_ansi_support;
|
||||
use nodtool::{run, SubCommand};
|
||||
use nodtool::{SubCommand, run};
|
||||
use supports_color::Stream;
|
||||
|
||||
#[derive(FromArgs, Debug)]
|
||||
@ -93,7 +93,7 @@ fn main() {
|
||||
// Try to enable ANSI support on Windows.
|
||||
let _ = enable_ansi_support();
|
||||
// Disable isatty check for supports-color. (e.g. when used with ninja)
|
||||
env::set_var("IGNORE_IS_TERMINAL", "1");
|
||||
unsafe { env::set_var("IGNORE_IS_TERMINAL", "1") };
|
||||
supports_color::on(Stream::Stdout).is_some_and(|c| c.has_basic)
|
||||
};
|
||||
|
||||
|
@ -5,7 +5,7 @@ pub mod shared;
|
||||
use std::{
|
||||
fmt,
|
||||
fmt::Write,
|
||||
path::{Path, MAIN_SEPARATOR},
|
||||
path::{MAIN_SEPARATOR, Path},
|
||||
};
|
||||
|
||||
pub fn path_display(path: &Path) -> PathDisplay { PathDisplay { path } }
|
||||
|
@ -7,11 +7,11 @@ use std::{
|
||||
|
||||
use indicatif::{ProgressBar, ProgressState, ProgressStyle};
|
||||
use nod::{
|
||||
Result, ResultContext,
|
||||
common::Compression,
|
||||
disc::DiscHeader,
|
||||
read::{DiscMeta, DiscOptions, DiscReader, PartitionEncryption},
|
||||
write::{DiscWriter, DiscWriterWeight, FormatOptions, ProcessOptions},
|
||||
Result, ResultContext,
|
||||
};
|
||||
use size::Size;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user