Add new flag to xp3 pack

This commit is contained in:
2025-11-10 17:06:20 +08:00
parent f9144184e0
commit 52dafaebf5
4 changed files with 18 additions and 1 deletions

View File

@@ -573,6 +573,11 @@ pub struct Arg {
#[arg(long, global = true)]
/// Do not add quote to translated text when exporting to m3t files.
pub m3t_no_quote: bool,
#[cfg(feature = "kirikiri-arc")]
#[arg(long, global = true)]
/// Disable adler32 checksum for Kirikiri XP3 archive when creating.
/// This will keep compatibility with https://github.com/arcusmaximus/KirikiriTools tool.
pub xp3_no_adler: bool,
#[command(subcommand)]
/// Command
pub command: Command,

View File

@@ -3053,6 +3053,8 @@ fn main() {
musica_xor_key: arg.musica_xor_key,
#[cfg(feature = "musica-arc")]
musica_compress: arg.musica_compress,
#[cfg(feature = "kirikiri-arc")]
xp3_no_adler: arg.xp3_no_adler,
});
match &arg.command {
args::Command::Export { input, output } => {

View File

@@ -75,6 +75,7 @@ pub struct Xp3ArchiveWriter<T: Write + Seek> {
processing_segments: Arc<Mutex<HashSet<[u8; 32]>>>,
use_zstd: bool,
zstd_compression_level: i32,
no_adler: bool,
}
impl Xp3ArchiveWriter<std::io::BufWriter<std::fs::File>> {
@@ -117,6 +118,7 @@ impl Xp3ArchiveWriter<std::io::BufWriter<std::fs::File>> {
processing_segments: Arc::new(Mutex::new(HashSet::new())),
use_zstd: config.xp3_zstd,
zstd_compression_level: config.zstd_compression_level,
no_adler: config.xp3_no_adler,
})
}
}
@@ -507,7 +509,11 @@ impl<T: Write + Seek + Sync + Send + 'static> Archive for Xp3ArchiveWriter<T> {
let adlr_data_size = 4;
file_chunk.write_all(CHUNK_ADLR)?;
file_chunk.write_u64(adlr_data_size)?;
file_chunk.write_u32(item.file_hash)?;
if self.no_adler {
file_chunk.write_u32(0)?;
} else {
file_chunk.write_u32(item.file_hash)?;
}
index_data.write_all(CHUNK_FILE)?;
let file_chunk = file_chunk.into_inner();
index_data.write_u64(file_chunk.len() as u64)?;

View File

@@ -503,6 +503,10 @@ pub struct ExtraConfig {
/// Workers count for packing file in Kirikiri XP3 archive in parallel. Default is 1.
/// This not works when segment is disabled.
pub xp3_pack_workers: usize,
#[cfg(feature = "kirikiri-arc")]
/// Disable adler32 checksum for Kirikiri XP3 archive when creating.
/// This will keep compatibility with https://github.com/arcusmaximus/KirikiriTools tool.
pub xp3_no_adler: bool,
#[cfg(feature = "kirikiri")]
/// Insert new language at the specified index in Kirikiri SCN script. If index is out of bounds, this flags will be ignored.
pub kirikiri_language_insert: bool,