mirror of
https://github.com/encounter/nod.git
synced 2026-07-10 12:18:48 -07:00
Migrate to Rust edition 2024
This commit is contained in:
@@ -19,7 +19,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
toolchain: [ stable, 1.81.0, nightly ]
|
toolchain: [ stable, 1.85.0, nightly ]
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
env:
|
env:
|
||||||
RUSTFLAGS: -D warnings
|
RUSTFLAGS: -D warnings
|
||||||
|
|||||||
+3
-3
@@ -1,6 +1,6 @@
|
|||||||
[workspace]
|
[workspace]
|
||||||
members = ["nod", "nodtool"]
|
members = ["nod", "nodtool"]
|
||||||
resolver = "2"
|
resolver = "3"
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
debug = 1
|
debug = 1
|
||||||
@@ -13,8 +13,8 @@ codegen-units = 1
|
|||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
version = "2.0.0-alpha.1"
|
version = "2.0.0-alpha.1"
|
||||||
edition = "2021"
|
edition = "2024"
|
||||||
rust-version = "1.81"
|
rust-version = "1.85"
|
||||||
authors = ["Luke Street <luke@street.dev>"]
|
authors = ["Luke Street <luke@street.dev>"]
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
repository = "https://github.com/encounter/nod"
|
repository = "https://github.com/encounter/nod"
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
[crates.io]: https://crates.io/crates/nod
|
[crates.io]: https://crates.io/crates/nod
|
||||||
[Api Rustdoc]: https://img.shields.io/badge/api-rustdoc-blue.svg
|
[Api Rustdoc]: https://img.shields.io/badge/api-rustdoc-blue.svg
|
||||||
[rustdoc]: https://docs.rs/nod
|
[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.
|
Library for reading and writing Nintendo Optical Disc (GameCube and Wii) images.
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -9,14 +9,14 @@ use tracing::debug;
|
|||||||
use zerocopy::{FromZeros, IntoBytes};
|
use zerocopy::{FromZeros, IntoBytes};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
Error, Result, ResultContext,
|
||||||
disc::{
|
disc::{
|
||||||
fst::{Fst, FstBuilder},
|
BI2_SIZE, BOOT_SIZE, BootHeader, DiscHeader, GCN_MAGIC, MINI_DVD_SIZE, SECTOR_SIZE,
|
||||||
BootHeader, DiscHeader, BI2_SIZE, BOOT_SIZE, GCN_MAGIC, MINI_DVD_SIZE, SECTOR_SIZE,
|
|
||||||
WII_MAGIC,
|
WII_MAGIC,
|
||||||
|
fst::{Fst, FstBuilder},
|
||||||
},
|
},
|
||||||
read::DiscStream,
|
read::DiscStream,
|
||||||
util::{array_ref, array_ref_mut, lfg::LaggedFibonacci, Align},
|
util::{Align, array_ref, array_ref_mut, lfg::LaggedFibonacci},
|
||||||
Error, Result, ResultContext,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub trait FileCallback: Clone + Send + Sync {
|
pub trait FileCallback: Clone + Send + Sync {
|
||||||
|
|||||||
+3
-3
@@ -5,12 +5,12 @@ use std::{borrow::Cow, fmt, str::FromStr, sync::Arc};
|
|||||||
use zerocopy::FromBytes;
|
use zerocopy::FromBytes;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
Error, Result,
|
||||||
disc::{
|
disc::{
|
||||||
fst::Fst, wii::WiiPartitionHeader, BootHeader, DebugHeader, DiscHeader, BB2_OFFSET,
|
BB2_OFFSET, BOOT_SIZE, BootHeader, DebugHeader, DiscHeader, SECTOR_SIZE, fst::Fst,
|
||||||
BOOT_SIZE, SECTOR_SIZE,
|
wii::WiiPartitionHeader,
|
||||||
},
|
},
|
||||||
util::array_ref,
|
util::array_ref,
|
||||||
Error, Result,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// SHA-1 hash bytes
|
/// SHA-1 hash bytes
|
||||||
|
|||||||
@@ -7,11 +7,11 @@ use std::{
|
|||||||
use zerocopy::FromZeros;
|
use zerocopy::FromZeros;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
Result,
|
||||||
common::KeyBytes,
|
common::KeyBytes,
|
||||||
disc::{wii::SECTOR_DATA_SIZE, DiscHeader, SECTOR_SIZE},
|
disc::{DiscHeader, SECTOR_SIZE, wii::SECTOR_DATA_SIZE},
|
||||||
io::block::{Block, BlockReader},
|
io::block::{Block, BlockReader},
|
||||||
util::impl_read_for_bufread,
|
util::impl_read_for_bufread,
|
||||||
Result,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
|||||||
+6
-4
@@ -4,11 +4,11 @@ use std::{borrow::Cow, ffi::CStr, mem::size_of};
|
|||||||
|
|
||||||
use encoding_rs::SHIFT_JIS;
|
use encoding_rs::SHIFT_JIS;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use zerocopy::{big_endian::*, FromBytes, FromZeros, Immutable, IntoBytes, KnownLayout};
|
use zerocopy::{FromBytes, FromZeros, Immutable, IntoBytes, KnownLayout, big_endian::*};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
util::{array_ref, static_assert},
|
|
||||||
Error, Result,
|
Error, Result,
|
||||||
|
util::{array_ref, static_assert},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// File system node kind.
|
/// File system node kind.
|
||||||
@@ -39,13 +39,14 @@ impl Node {
|
|||||||
/// Create a new node.
|
/// Create a new node.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new(kind: NodeKind, name_offset: u32, offset: u64, length: u32, is_wii: bool) -> Self {
|
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 {
|
Self {
|
||||||
kind: match kind {
|
kind: match kind {
|
||||||
NodeKind::File => 0,
|
NodeKind::File => 0,
|
||||||
NodeKind::Directory => 1,
|
NodeKind::Directory => 1,
|
||||||
NodeKind::Invalid => u8::MAX,
|
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 {
|
offset: U32::new(match kind {
|
||||||
NodeKind::File if is_wii => (offset / 4) as u32,
|
NodeKind::File if is_wii => (offset / 4) as u32,
|
||||||
_ => offset as u32,
|
_ => offset as u32,
|
||||||
@@ -91,7 +92,8 @@ impl Node {
|
|||||||
/// Set the name offset of the node.
|
/// Set the name offset of the node.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_name_offset(&mut self, name_offset: u32) {
|
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)
|
/// For files, this is the partition offset of the file data. (Wii: >> 2)
|
||||||
|
|||||||
+3
-3
@@ -8,10 +8,11 @@ use std::{
|
|||||||
use zerocopy::{FromBytes, FromZeros, IntoBytes};
|
use zerocopy::{FromBytes, FromZeros, IntoBytes};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
Result, ResultContext,
|
||||||
disc::{
|
disc::{
|
||||||
preloader::{fetch_sector_group, Preloader, SectorGroup, SectorGroupRequest},
|
ApploaderHeader, BB2_OFFSET, BI2_SIZE, BOOT_SIZE, BootHeader, DolHeader, SECTOR_GROUP_SIZE,
|
||||||
ApploaderHeader, BootHeader, DolHeader, BB2_OFFSET, BI2_SIZE, BOOT_SIZE, SECTOR_GROUP_SIZE,
|
|
||||||
SECTOR_SIZE,
|
SECTOR_SIZE,
|
||||||
|
preloader::{Preloader, SectorGroup, SectorGroupRequest, fetch_sector_group},
|
||||||
},
|
},
|
||||||
io::block::BlockReader,
|
io::block::BlockReader,
|
||||||
read::{DiscStream, PartitionEncryption, PartitionMeta, PartitionReader},
|
read::{DiscStream, PartitionEncryption, PartitionMeta, PartitionReader},
|
||||||
@@ -19,7 +20,6 @@ use crate::{
|
|||||||
impl_read_for_bufread,
|
impl_read_for_bufread,
|
||||||
read::{read_arc, read_arc_slice, read_from},
|
read::{read_arc, read_arc_slice, read_from},
|
||||||
},
|
},
|
||||||
Result, ResultContext,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct PartitionReaderGC {
|
pub struct PartitionReaderGC {
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ use zerocopy::{FromZeros, IntoBytes};
|
|||||||
use crate::{
|
use crate::{
|
||||||
common::HashBytes,
|
common::HashBytes,
|
||||||
disc::{
|
disc::{
|
||||||
wii::{HASHES_SIZE, SECTOR_DATA_SIZE},
|
|
||||||
SECTOR_GROUP_SIZE, SECTOR_SIZE,
|
SECTOR_GROUP_SIZE, SECTOR_SIZE,
|
||||||
|
wii::{HASHES_SIZE, SECTOR_DATA_SIZE},
|
||||||
},
|
},
|
||||||
util::{array_ref, array_ref_mut, digest::sha1_hash},
|
util::{array_ref, array_ref_mut, digest::sha1_hash},
|
||||||
};
|
};
|
||||||
|
|||||||
+5
-21
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
use std::{ffi::CStr, str::from_utf8};
|
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};
|
use crate::{common::MagicBytes, util::static_assert};
|
||||||
|
|
||||||
@@ -166,11 +166,7 @@ impl BootHeader {
|
|||||||
/// Offset within the partition to the main DOL.
|
/// Offset within the partition to the main DOL.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn dol_offset(&self, is_wii: bool) -> u64 {
|
pub fn dol_offset(&self, is_wii: bool) -> u64 {
|
||||||
if is_wii {
|
if is_wii { self.dol_offset.get() as u64 * 4 } else { self.dol_offset.get() as u64 }
|
||||||
self.dol_offset.get() as u64 * 4
|
|
||||||
} else {
|
|
||||||
self.dol_offset.get() as u64
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the offset within the partition to the main DOL.
|
/// 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).
|
/// Offset within the partition to the file system table (FST).
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn fst_offset(&self, is_wii: bool) -> u64 {
|
pub fn fst_offset(&self, is_wii: bool) -> u64 {
|
||||||
if is_wii {
|
if is_wii { self.fst_offset.get() as u64 * 4 } else { self.fst_offset.get() as u64 }
|
||||||
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).
|
/// 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).
|
/// Size of the file system table (FST).
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn fst_size(&self, is_wii: bool) -> u64 {
|
pub fn fst_size(&self, is_wii: bool) -> u64 {
|
||||||
if is_wii {
|
if is_wii { self.fst_size.get() as u64 * 4 } else { self.fst_size.get() as u64 }
|
||||||
self.fst_size.get() as u64 * 4
|
|
||||||
} else {
|
|
||||||
self.fst_size.get() as u64
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the size of the file system table (FST).
|
/// 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.
|
/// Maximum size of the file system table (FST) across multi-disc games.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn fst_max_size(&self, is_wii: bool) -> u64 {
|
pub fn fst_max_size(&self, is_wii: bool) -> u64 {
|
||||||
if is_wii {
|
if is_wii { self.fst_max_size.get() as u64 * 4 } else { self.fst_max_size.get() as u64 }
|
||||||
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.
|
/// 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 crossbeam_utils::sync::WaitGroup;
|
||||||
use lru::LruCache;
|
use lru::LruCache;
|
||||||
use polonius_the_crab::{polonius, polonius_return};
|
use polonius_the_crab::{polonius, polonius_return};
|
||||||
use simple_moving_average::{SingleSumSMA, SMA};
|
use simple_moving_average::{SMA, SingleSumSMA};
|
||||||
use tracing::{debug, error, instrument, span, Level};
|
use tracing::{Level, debug, error, instrument, span};
|
||||||
use zerocopy::FromZeros;
|
use zerocopy::FromZeros;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
IoResultContext,
|
||||||
common::PartitionInfo,
|
common::PartitionInfo,
|
||||||
disc::{
|
disc::{
|
||||||
hashes::{hash_sector_group, GroupHashes},
|
|
||||||
wii::HASHES_SIZE,
|
|
||||||
DiscHeader, SECTOR_GROUP_SIZE, SECTOR_SIZE,
|
DiscHeader, SECTOR_GROUP_SIZE, SECTOR_SIZE,
|
||||||
|
hashes::{GroupHashes, hash_sector_group},
|
||||||
|
wii::HASHES_SIZE,
|
||||||
},
|
},
|
||||||
io::{
|
io::{
|
||||||
block::{Block, BlockKind, BlockReader},
|
block::{Block, BlockKind, BlockReader},
|
||||||
@@ -33,7 +34,6 @@ use crate::{
|
|||||||
aes::{decrypt_sector, encrypt_sector},
|
aes::{decrypt_sector, encrypt_sector},
|
||||||
array_ref_mut,
|
array_ref_mut,
|
||||||
},
|
},
|
||||||
IoResultContext,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||||
|
|||||||
@@ -10,20 +10,21 @@ use tracing::warn;
|
|||||||
use zerocopy::{FromBytes, IntoBytes};
|
use zerocopy::{FromBytes, IntoBytes};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
Error, Result, ResultContext,
|
||||||
common::{PartitionInfo, PartitionKind},
|
common::{PartitionInfo, PartitionKind},
|
||||||
disc::{
|
disc::{
|
||||||
|
BB2_OFFSET, BOOT_SIZE, BootHeader, DL_DVD_SIZE, DiscHeader, MINI_DVD_SIZE,
|
||||||
|
SECTOR_GROUP_SIZE, SECTOR_SIZE, SL_DVD_SIZE,
|
||||||
direct::{DirectDiscReader, DirectDiscReaderMode},
|
direct::{DirectDiscReader, DirectDiscReaderMode},
|
||||||
fst::{Fst, NodeKind},
|
fst::{Fst, NodeKind},
|
||||||
gcn::{read_fst, PartitionReaderGC},
|
gcn::{PartitionReaderGC, read_fst},
|
||||||
preloader::{
|
preloader::{
|
||||||
fetch_sector_group, Preloader, SectorGroup, SectorGroupLoader, SectorGroupRequest,
|
Preloader, SectorGroup, SectorGroupLoader, SectorGroupRequest, fetch_sector_group,
|
||||||
},
|
},
|
||||||
wii::{
|
wii::{
|
||||||
PartitionReaderWii, WiiPartEntry, WiiPartGroup, WiiPartitionHeader, REGION_OFFSET,
|
PartitionReaderWii, REGION_OFFSET, REGION_SIZE, WII_PART_GROUP_OFF, WiiPartEntry,
|
||||||
REGION_SIZE, WII_PART_GROUP_OFF,
|
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,
|
io::block::BlockReader,
|
||||||
read::{DiscMeta, DiscOptions, PartitionEncryption, PartitionOptions, PartitionReader},
|
read::{DiscMeta, DiscOptions, PartitionEncryption, PartitionOptions, PartitionReader},
|
||||||
@@ -31,7 +32,6 @@ use crate::{
|
|||||||
array_ref, impl_read_for_bufread,
|
array_ref, impl_read_for_bufread,
|
||||||
read::{read_arc, read_from, read_vec},
|
read::{read_arc, read_from, read_vec},
|
||||||
},
|
},
|
||||||
Error, Result, ResultContext,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct DiscReader {
|
pub struct DiscReader {
|
||||||
|
|||||||
+4
-4
@@ -8,14 +8,15 @@ use std::{
|
|||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
|
|
||||||
use zerocopy::{big_endian::*, FromBytes, Immutable, IntoBytes, KnownLayout};
|
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout, big_endian::*};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
Error, Result, ResultContext,
|
||||||
common::{HashBytes, KeyBytes, PartitionInfo},
|
common::{HashBytes, KeyBytes, PartitionInfo},
|
||||||
disc::{
|
disc::{
|
||||||
gcn::{read_part_meta, PartitionReaderGC},
|
|
||||||
preloader::{fetch_sector_group, Preloader, SectorGroup, SectorGroupRequest},
|
|
||||||
SECTOR_GROUP_SIZE, SECTOR_SIZE,
|
SECTOR_GROUP_SIZE, SECTOR_SIZE,
|
||||||
|
gcn::{PartitionReaderGC, read_part_meta},
|
||||||
|
preloader::{Preloader, SectorGroup, SectorGroupRequest, fetch_sector_group},
|
||||||
},
|
},
|
||||||
io::block::BlockReader,
|
io::block::BlockReader,
|
||||||
read::{PartitionEncryption, PartitionMeta, PartitionOptions, PartitionReader},
|
read::{PartitionEncryption, PartitionMeta, PartitionOptions, PartitionReader},
|
||||||
@@ -27,7 +28,6 @@ use crate::{
|
|||||||
read::{read_arc, read_arc_slice},
|
read::{read_arc, read_arc_slice},
|
||||||
static_assert,
|
static_assert,
|
||||||
},
|
},
|
||||||
Error, Result, ResultContext,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Size in bytes of the hashes block in a Wii disc sector
|
/// Size in bytes of the hashes block in a Wii disc sector
|
||||||
|
|||||||
@@ -8,15 +8,15 @@ use dyn_clone::DynClone;
|
|||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
Error, Result, ResultContext,
|
||||||
common::PartitionInfo,
|
common::PartitionInfo,
|
||||||
disc::{
|
disc::{
|
||||||
|
SECTOR_SIZE,
|
||||||
reader::DiscReader,
|
reader::DiscReader,
|
||||||
wii::{HASHES_SIZE, SECTOR_DATA_SIZE},
|
wii::{HASHES_SIZE, SECTOR_DATA_SIZE},
|
||||||
SECTOR_SIZE,
|
|
||||||
},
|
},
|
||||||
util::{aes::decrypt_sector_b2b, array_ref, array_ref_mut, lfg::LaggedFibonacci},
|
util::{aes::decrypt_sector_b2b, array_ref, array_ref_mut, lfg::LaggedFibonacci},
|
||||||
write::{DiscFinalization, DiscWriterWeight, ProcessOptions},
|
write::{DiscFinalization, DiscWriterWeight, ProcessOptions},
|
||||||
Error, Result, ResultContext,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A callback for writing disc data.
|
/// A callback for writing disc data.
|
||||||
|
|||||||
+3
-3
@@ -3,10 +3,11 @@ use std::{fs, io, io::Read, path::Path};
|
|||||||
use dyn_clone::DynClone;
|
use dyn_clone::DynClone;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
Error, Result, ResultContext,
|
||||||
common::{Format, KeyBytes, MagicBytes, PartitionInfo},
|
common::{Format, KeyBytes, MagicBytes, PartitionInfo},
|
||||||
disc::{
|
disc::{
|
||||||
wii::{HASHES_SIZE, SECTOR_DATA_SIZE},
|
|
||||||
DiscHeader, GCN_MAGIC, SECTOR_SIZE, WII_MAGIC,
|
DiscHeader, GCN_MAGIC, SECTOR_SIZE, WII_MAGIC,
|
||||||
|
wii::{HASHES_SIZE, SECTOR_DATA_SIZE},
|
||||||
},
|
},
|
||||||
io::{
|
io::{
|
||||||
split::SplitFileReader,
|
split::SplitFileReader,
|
||||||
@@ -14,7 +15,6 @@ use crate::{
|
|||||||
},
|
},
|
||||||
read::{DiscMeta, DiscStream},
|
read::{DiscMeta, DiscStream},
|
||||||
util::{aes::decrypt_sector, array_ref, array_ref_mut, lfg::LaggedFibonacci, read::read_from},
|
util::{aes::decrypt_sector, array_ref, array_ref_mut, lfg::LaggedFibonacci, read::read_from},
|
||||||
Error, Result, ResultContext,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Block reader trait for reading disc images.
|
/// 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()));
|
return Err(Error::DiscFormat("GCZ support is disabled".to_string()));
|
||||||
}
|
}
|
||||||
Some(Format::Nfs) => {
|
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::Wbfs) => crate::io::wbfs::BlockReaderWBFS::new(stream)?,
|
||||||
Some(Format::Wia | Format::Rvz) => crate::io::wia::BlockReaderWIA::new(stream)?,
|
Some(Format::Wia | Format::Rvz) => crate::io::wia::BlockReaderWIA::new(stream)?,
|
||||||
|
|||||||
+5
-5
@@ -6,17 +6,18 @@ use std::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use bytes::{BufMut, Bytes, BytesMut};
|
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::{
|
use crate::{
|
||||||
|
Error, Result, ResultContext,
|
||||||
common::{Compression, Format, MagicBytes},
|
common::{Compression, Format, MagicBytes},
|
||||||
disc::{
|
disc::{
|
||||||
|
SECTOR_SIZE,
|
||||||
reader::DiscReader,
|
reader::DiscReader,
|
||||||
writer::{
|
writer::{
|
||||||
check_block, par_process, read_block, BlockProcessor, BlockResult, CheckBlockResult,
|
BlockProcessor, BlockResult, CheckBlockResult, DataCallback, DiscWriter, check_block,
|
||||||
DataCallback, DiscWriter,
|
par_process, read_block,
|
||||||
},
|
},
|
||||||
SECTOR_SIZE,
|
|
||||||
},
|
},
|
||||||
io::{
|
io::{
|
||||||
block::{Block, BlockKind, BlockReader, CISO_MAGIC},
|
block::{Block, BlockKind, BlockReader, CISO_MAGIC},
|
||||||
@@ -31,7 +32,6 @@ use crate::{
|
|||||||
static_assert,
|
static_assert,
|
||||||
},
|
},
|
||||||
write::{DiscFinalization, DiscWriterWeight, FormatOptions, ProcessOptions},
|
write::{DiscFinalization, DiscWriterWeight, FormatOptions, ProcessOptions},
|
||||||
Error, Result, ResultContext,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const CISO_MAP_SIZE: usize = SECTOR_SIZE - 8;
|
pub const CISO_MAP_SIZE: usize = SECTOR_SIZE - 8;
|
||||||
|
|||||||
+4
-4
@@ -7,14 +7,15 @@ use std::{
|
|||||||
|
|
||||||
use adler::adler32_slice;
|
use adler::adler32_slice;
|
||||||
use bytes::{BufMut, Bytes, BytesMut};
|
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::{
|
use crate::{
|
||||||
|
Error, Result, ResultContext,
|
||||||
common::{Compression, Format, MagicBytes},
|
common::{Compression, Format, MagicBytes},
|
||||||
disc::{
|
disc::{
|
||||||
reader::DiscReader,
|
|
||||||
writer::{par_process, read_block, BlockProcessor, BlockResult, DataCallback, DiscWriter},
|
|
||||||
SECTOR_SIZE,
|
SECTOR_SIZE,
|
||||||
|
reader::DiscReader,
|
||||||
|
writer::{BlockProcessor, BlockResult, DataCallback, DiscWriter, par_process, read_block},
|
||||||
},
|
},
|
||||||
io::block::{Block, BlockKind, BlockReader, GCZ_MAGIC},
|
io::block::{Block, BlockKind, BlockReader, GCZ_MAGIC},
|
||||||
read::{DiscMeta, DiscStream},
|
read::{DiscMeta, DiscStream},
|
||||||
@@ -25,7 +26,6 @@ use crate::{
|
|||||||
static_assert,
|
static_assert,
|
||||||
},
|
},
|
||||||
write::{DiscFinalization, DiscWriterWeight, FormatOptions, ProcessOptions},
|
write::{DiscFinalization, DiscWriterWeight, FormatOptions, ProcessOptions},
|
||||||
Error, Result, ResultContext,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// GCZ header (little endian)
|
/// GCZ header (little endian)
|
||||||
|
|||||||
+2
-2
@@ -4,17 +4,17 @@ use std::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
Result, ResultContext,
|
||||||
common::Format,
|
common::Format,
|
||||||
disc::{
|
disc::{
|
||||||
|
SECTOR_SIZE,
|
||||||
reader::DiscReader,
|
reader::DiscReader,
|
||||||
writer::{DataCallback, DiscWriter},
|
writer::{DataCallback, DiscWriter},
|
||||||
SECTOR_SIZE,
|
|
||||||
},
|
},
|
||||||
io::block::{Block, BlockKind, BlockReader},
|
io::block::{Block, BlockKind, BlockReader},
|
||||||
read::{DiscMeta, DiscStream},
|
read::{DiscMeta, DiscStream},
|
||||||
util::digest::DigestManager,
|
util::digest::DigestManager,
|
||||||
write::{DiscFinalization, DiscWriterWeight, ProcessOptions},
|
write::{DiscFinalization, DiscWriterWeight, ProcessOptions},
|
||||||
Result, ResultContext,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
|||||||
+2
-2
@@ -7,9 +7,10 @@ use std::{
|
|||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
|
|
||||||
use zerocopy::{big_endian::U32, FromBytes, FromZeros, Immutable, IntoBytes, KnownLayout};
|
use zerocopy::{FromBytes, FromZeros, Immutable, IntoBytes, KnownLayout, big_endian::U32};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
Error, Result, ResultContext,
|
||||||
common::{Format, KeyBytes, MagicBytes},
|
common::{Format, KeyBytes, MagicBytes},
|
||||||
disc::SECTOR_SIZE,
|
disc::SECTOR_SIZE,
|
||||||
io::{
|
io::{
|
||||||
@@ -18,7 +19,6 @@ use crate::{
|
|||||||
},
|
},
|
||||||
read::DiscMeta,
|
read::DiscMeta,
|
||||||
util::{aes::aes_cbc_decrypt, array_ref_mut, read::read_arc, static_assert},
|
util::{aes::aes_cbc_decrypt, array_ref_mut, read::read_arc, static_assert},
|
||||||
Error, Result, ResultContext,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const NFS_END_MAGIC: MagicBytes = *b"SGGE";
|
pub const NFS_END_MAGIC: MagicBytes = *b"SGGE";
|
||||||
|
|||||||
+6
-6
@@ -5,27 +5,27 @@ use std::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use bytes::{BufMut, Bytes, BytesMut};
|
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::{
|
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},
|
common::{Compression, Format, MagicBytes, PartitionKind},
|
||||||
disc::{
|
disc::{
|
||||||
|
BB2_OFFSET, BootHeader, DiscHeader, SECTOR_SIZE,
|
||||||
fst::Fst,
|
fst::Fst,
|
||||||
gcn::{read_dol, read_fst},
|
gcn::{read_dol, read_fst},
|
||||||
reader::DiscReader,
|
reader::DiscReader,
|
||||||
writer::{DataCallback, DiscWriter},
|
writer::{DataCallback, DiscWriter},
|
||||||
BootHeader, DiscHeader, BB2_OFFSET, SECTOR_SIZE,
|
|
||||||
},
|
},
|
||||||
io::block::{Block, BlockKind, BlockReader, TGC_MAGIC},
|
io::block::{Block, BlockKind, BlockReader, TGC_MAGIC},
|
||||||
read::{DiscMeta, DiscStream, PartitionOptions, PartitionReader},
|
read::{DiscMeta, DiscStream, PartitionOptions, PartitionReader},
|
||||||
util::{
|
util::{
|
||||||
array_ref,
|
Align, array_ref,
|
||||||
read::{read_arc, read_arc_slice, read_from, read_with_zero_fill},
|
read::{read_arc, read_arc_slice, read_from, read_with_zero_fill},
|
||||||
static_assert, Align,
|
static_assert,
|
||||||
},
|
},
|
||||||
write::{DiscFinalization, DiscWriterWeight, FormatOptions, ProcessOptions},
|
write::{DiscFinalization, DiscWriterWeight, FormatOptions, ProcessOptions},
|
||||||
Error, Result, ResultContext,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// TGC header (big endian)
|
/// TGC header (big endian)
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user