mirror of
https://gitea.tendokyu.moe/beerpsi/fsdecrypt.git
synced 2026-10-06 05:37:54 +03:00
feat: name output folder after the input .app file
Output directory is now derived from the input .app path (without extension) instead of the intermediate VHD filename. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
2121b43699
commit
068badad7e
+4
-2
@@ -393,7 +393,8 @@ fn main() -> Result<()> {
|
||||
if deltas.is_empty() {
|
||||
// Standalone base VHD, just extract
|
||||
if let Some(base) = base {
|
||||
if let Err(e) = vhd::extract_vhd(&base.vhd_path) {
|
||||
let output_dir = base.input_path.with_extension("");
|
||||
if let Err(e) = vhd::extract_vhd(&base.vhd_path, &output_dir) {
|
||||
println!("WARNING: VHD extraction failed: {e:#}");
|
||||
}
|
||||
}
|
||||
@@ -408,7 +409,8 @@ fn main() -> Result<()> {
|
||||
|
||||
// Merge + extract each delta with the base (pure Rust, no admin needed)
|
||||
for delta in &deltas {
|
||||
if let Err(e) = vhd::extract_merged_vhd(&base.vhd_path, &delta.vhd_path) {
|
||||
let output_dir = delta.input_path.with_extension("");
|
||||
if let Err(e) = vhd::extract_merged_vhd(&base.vhd_path, &delta.vhd_path, &output_dir) {
|
||||
println!("WARNING: Merged VHD extraction failed: {e:#}");
|
||||
}
|
||||
}
|
||||
|
||||
+8
-8
@@ -656,13 +656,13 @@ fn extract_ntfs_to_dir<T: Read + Seek>(fs: &mut T, output_dir: &Path, prefix: &s
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/// Extract all files from a single VHD's NTFS filesystem, then delete the VHD.
|
||||
pub fn extract_vhd(vhd_path: &Path) -> Result<()> {
|
||||
let output_dir = vhd_path.with_extension("");
|
||||
/// The `output_dir` is where files are extracted to.
|
||||
pub fn extract_vhd(vhd_path: &Path, output_dir: &Path) -> Result<()> {
|
||||
println!("Extracting VHD: {}", vhd_path.display());
|
||||
|
||||
let mut vhd = VhdReader::new(File::open(vhd_path)?).map_err(|e| anyhow!(e))?;
|
||||
let prefix = vhd_path.file_name().unwrap_or_default().to_string_lossy().to_string();
|
||||
extract_ntfs_to_dir(&mut vhd, &output_dir, &prefix)?;
|
||||
let prefix = output_dir.file_name().unwrap_or_default().to_string_lossy().to_string();
|
||||
extract_ntfs_to_dir(&mut vhd, output_dir, &prefix)?;
|
||||
|
||||
println!("Extracted to: {}", output_dir.display());
|
||||
|
||||
@@ -675,16 +675,16 @@ pub fn extract_vhd(vhd_path: &Path) -> Result<()> {
|
||||
|
||||
/// Extract files from a merged view of base + delta VHDs (pure Rust, no admin needed).
|
||||
/// Reads delta blocks where available, falls back to base. Deletes both VHDs after.
|
||||
pub fn extract_merged_vhd(base_path: &Path, delta_path: &Path) -> Result<()> {
|
||||
let output_dir = base_path.with_extension("");
|
||||
/// The `output_dir` is where files are extracted to.
|
||||
pub fn extract_merged_vhd(base_path: &Path, delta_path: &Path, output_dir: &Path) -> Result<()> {
|
||||
println!("Extracting merged VHD: {} + {}", base_path.display(), delta_path.display());
|
||||
|
||||
let base = File::open(base_path)?;
|
||||
let delta = File::open(delta_path)?;
|
||||
let mut merged = MergedVhdReader::new(base, delta).map_err(|e| anyhow!(e))?;
|
||||
|
||||
let prefix = base_path.file_name().unwrap_or_default().to_string_lossy().to_string();
|
||||
extract_ntfs_to_dir(&mut merged, &output_dir, &prefix)?;
|
||||
let prefix = output_dir.file_name().unwrap_or_default().to_string_lossy().to_string();
|
||||
extract_ntfs_to_dir(&mut merged, output_dir, &prefix)?;
|
||||
|
||||
println!("Extracted to: {}", output_dir.display());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user