From 601e217276841e9e67c35a5477fdc1698f89918a Mon Sep 17 00:00:00 2001 From: Eigeen Date: Fri, 25 Jul 2025 19:33:47 +0800 Subject: [PATCH] use fs_err for better std::fs errors --- Cargo.lock | 10 ++++++++++ Cargo.toml | 1 + src/main.rs | 9 +++++---- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 78ce29d..b1047b9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -247,6 +247,15 @@ dependencies = [ "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]] name = "gdeflate" version = "0.4.1" @@ -392,6 +401,7 @@ dependencies = [ "color-eyre", "colored", "dialoguer", + "fs-err", "indicatif", "parking_lot", "rayon", diff --git a/Cargo.toml b/Cargo.toml index e35cbc4..c745ee3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,3 +17,4 @@ indicatif = "0.18" rayon = "1.10" parking_lot = "0.12" colored = "3.0" +fs-err = "3.1.1" diff --git a/src/main.rs b/src/main.rs index 83b16ab..dc66fa3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,4 @@ use std::{ - fs::{self, OpenOptions}, io::{self, Write}, path::Path, sync::{ @@ -9,9 +8,12 @@ use std::{ time::Duration, }; +use fs_err as fs; + use color_eyre::eyre::bail; use colored::Colorize; use dialoguer::{Input, Select, theme::ColorfulTheme}; +use fs::OpenOptions; use indicatif::{HumanBytes, ProgressBar, ProgressStyle}; use parking_lot::Mutex; 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 pak_writer { + match Arc::try_unwrap(pak_writer_mtx) { Ok(pak_writer) => pak_writer.into_inner().finish()?, Err(_) => panic!("Arc::try_unwrap failed"), }; @@ -187,7 +188,7 @@ fn main_entry() -> color_eyre::Result<()> { println!("{}", "Done!".cyan().bold()); if !use_full_package_mode { 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`." ); }