From 772898009b45b3adad1430e1e00a6532d0e6573e Mon Sep 17 00:00:00 2001 From: MattNL Date: Thu, 2 Mar 2023 06:41:09 -0500 Subject: [PATCH] Fixed "Extract" tool not working properly on SubPCK folders --- PCK-Studio/MainForm.cs | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/PCK-Studio/MainForm.cs b/PCK-Studio/MainForm.cs index f0f69986..17d72700 100644 --- a/PCK-Studio/MainForm.cs +++ b/PCK-Studio/MainForm.cs @@ -587,14 +587,39 @@ namespace PckStudio dialog.Description = @"Select destination folder"; if (dialog.ShowDialog() == DialogResult.OK) { - currentPCK.Files.ForEach(file => + if(IsSubPCKNode(node.FullPath) && node.Tag == null) { - if (file.Filename.StartsWith(selectedFolder)) + GetAllChildNodes(node.Nodes).ForEach(fileNode => { - Directory.CreateDirectory($"{dialog.SelectedPath}/{Path.GetDirectoryName(file.Filename)}"); - File.WriteAllBytes($"{dialog.SelectedPath}/{file.Filename}", file.Data); + if(fileNode.Tag is PCKFile.FileData file) + { + Directory.CreateDirectory($"{dialog.SelectedPath}/{Path.GetDirectoryName(file.Filename)}"); + File.WriteAllBytes($"{dialog.SelectedPath}/{file.Filename}", file.Data); + if (file.Properties.Count > 0) + { + using var fs = File.CreateText($"{dialog.SelectedPath}/{file.Filename}.txt"); + file.Properties.ForEach(property => fs.WriteLine($"{property.Item1}: {property.Item2}")); + } + } } - }); + ); + } + else + { + currentPCK.Files.ForEach(file => + { + if (file.Filename.StartsWith(selectedFolder)) + { + Directory.CreateDirectory($"{dialog.SelectedPath}/{Path.GetDirectoryName(file.Filename)}"); + File.WriteAllBytes($"{dialog.SelectedPath}/{file.Filename}", file.Data); + if (file.Properties.Count > 0) + { + using var fs = File.CreateText($"{dialog.SelectedPath}/{file.Filename}.txt"); + file.Properties.ForEach(property => fs.WriteLine($"{property.Item1}: {property.Item2}")); + } + } + }); + } MessageBox.Show("Folder Extracted"); } }