use fs_err for better std::fs errors

This commit is contained in:
2025-07-25 19:33:47 +08:00
parent 87d808dc3b
commit 601e217276
3 changed files with 16 additions and 4 deletions

10
Cargo.lock generated
View File

@@ -247,6 +247,15 @@ dependencies = [
"miniz_oxide", "miniz_oxide",
] ]
[[package]]
name = "fs-err"
version = "3.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "88d7be93788013f265201256d58f04936a8079ad5dc898743aa20525f503b683"
dependencies = [
"autocfg",
]
[[package]] [[package]]
name = "gdeflate" name = "gdeflate"
version = "0.4.1" version = "0.4.1"
@@ -392,6 +401,7 @@ dependencies = [
"color-eyre", "color-eyre",
"colored", "colored",
"dialoguer", "dialoguer",
"fs-err",
"indicatif", "indicatif",
"parking_lot", "parking_lot",
"rayon", "rayon",

View File

@@ -17,3 +17,4 @@ indicatif = "0.18"
rayon = "1.10" rayon = "1.10"
parking_lot = "0.12" parking_lot = "0.12"
colored = "3.0" colored = "3.0"
fs-err = "3.1.1"

View File

@@ -1,5 +1,4 @@
use std::{ use std::{
fs::{self, OpenOptions},
io::{self, Write}, io::{self, Write},
path::Path, path::Path,
sync::{ sync::{
@@ -9,9 +8,12 @@ use std::{
time::Duration, time::Duration,
}; };
use fs_err as fs;
use color_eyre::eyre::bail; use color_eyre::eyre::bail;
use colored::Colorize; use colored::Colorize;
use dialoguer::{Input, Select, theme::ColorfulTheme}; use dialoguer::{Input, Select, theme::ColorfulTheme};
use fs::OpenOptions;
use indicatif::{HumanBytes, ProgressBar, ProgressStyle}; use indicatif::{HumanBytes, ProgressBar, ProgressStyle};
use parking_lot::Mutex; use parking_lot::Mutex;
use rayon::iter::{IntoParallelRefIterator, ParallelIterator}; use rayon::iter::{IntoParallelRefIterator, ParallelIterator};
@@ -177,8 +179,7 @@ fn main_entry() -> color_eyre::Result<()> {
); );
} }
let pak_writer = Arc::try_unwrap(pak_writer_mtx); match Arc::try_unwrap(pak_writer_mtx) {
match pak_writer {
Ok(pak_writer) => pak_writer.into_inner().finish()?, Ok(pak_writer) => pak_writer.into_inner().finish()?,
Err(_) => panic!("Arc::try_unwrap failed"), Err(_) => panic!("Arc::try_unwrap failed"),
}; };
@@ -187,7 +188,7 @@ fn main_entry() -> color_eyre::Result<()> {
println!("{}", "Done!".cyan().bold()); println!("{}", "Done!".cyan().bold());
if !use_full_package_mode { if !use_full_package_mode {
println!( println!(
"You should rename the output file like `re_chunk_000.pak.sub_000.pak.patch_xxx.pak`, or manage it by your favorite mod manager." "You should rename the output file like `re_chunk_000.pak.sub_000.pak.patch_xxx.pak`."
); );
} }