From 08991e895226032c1e1d5bf781258baccea6724f Mon Sep 17 00:00:00 2001 From: Mayx Date: Thu, 12 Jun 2025 09:07:38 +0000 Subject: [PATCH 1/3] fix Case-sensitive directory preservation in project reconstruction #27 --- .../ProjectReconstructor.cs | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/RPGMakerDecrypter.MVMZ/ProjectReconstructor.cs b/RPGMakerDecrypter.MVMZ/ProjectReconstructor.cs index 2cd60bb..f2d6bab 100644 --- a/RPGMakerDecrypter.MVMZ/ProjectReconstructor.cs +++ b/RPGMakerDecrypter.MVMZ/ProjectReconstructor.cs @@ -34,14 +34,32 @@ public virtual void Reconstruct(string deploymentPath, string outputPath) Directory.CreateDirectory(outputPath); } + // 获取源目录下所有一级子目录,建立小写->原始名映射 + var sourceDirs = Directory.Exists(deploymentPath) + ? Directory.GetDirectories(deploymentPath, "*", SearchOption.TopDirectoryOnly) + : new string[0]; + var sourceDirMap = sourceDirs.ToDictionary( + d => Path.GetFileName(d).ToLowerInvariant(), + d => Path.GetFileName(d)); + foreach (var directory in _directories) { - CopyDirectory(Path.Combine(deploymentPath, directory), Path.Combine(outputPath, directory)); + // 查找实际存在的目录名(忽略大小写) + if (sourceDirMap.TryGetValue(directory.ToLowerInvariant(), out var realDirName)) + { + CopyDirectory( + Path.Combine(deploymentPath, realDirName), + Path.Combine(outputPath, realDirName)); + } } foreach (var file in _files) { - File.Copy(Path.Combine(deploymentPath, file), Path.Combine(outputPath, file)); + var srcFile = Path.Combine(deploymentPath, file); + if (File.Exists(srcFile)) + { + File.Copy(srcFile, Path.Combine(outputPath, file)); + } } CreateProjectFile(outputPath); From f0af70ede8d03fec6958ebbc26132664fb01958f Mon Sep 17 00:00:00 2001 From: Mayx Date: Thu, 12 Jun 2025 19:48:50 +0800 Subject: [PATCH 2/3] Update ProjectReconstructor.cs --- RPGMakerDecrypter.MVMZ/ProjectReconstructor.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/RPGMakerDecrypter.MVMZ/ProjectReconstructor.cs b/RPGMakerDecrypter.MVMZ/ProjectReconstructor.cs index f2d6bab..43ff6f9 100644 --- a/RPGMakerDecrypter.MVMZ/ProjectReconstructor.cs +++ b/RPGMakerDecrypter.MVMZ/ProjectReconstructor.cs @@ -1,4 +1,5 @@ using System.IO; +using System.Linq; namespace RPGMakerDecrypter.MVMZ { @@ -87,4 +88,4 @@ private void CopyDirectory(string sourceDir, string destinationDir) } } } -} \ No newline at end of file +} From 76a3a4e2aea4daa0356814968ffd798b963a4c24 Mon Sep 17 00:00:00 2001 From: Mayx Date: Thu, 19 Jun 2025 00:40:16 +0800 Subject: [PATCH 3/3] Refactor variable names to use full words for clarity --- .../ProjectReconstructor.cs | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/RPGMakerDecrypter.MVMZ/ProjectReconstructor.cs b/RPGMakerDecrypter.MVMZ/ProjectReconstructor.cs index 43ff6f9..8f54e7a 100644 --- a/RPGMakerDecrypter.MVMZ/ProjectReconstructor.cs +++ b/RPGMakerDecrypter.MVMZ/ProjectReconstructor.cs @@ -10,6 +10,7 @@ public abstract class ProjectReconstructor "audio", "css", "data", + "dataex", "effects", "fonts", "icon", @@ -35,31 +36,31 @@ public virtual void Reconstruct(string deploymentPath, string outputPath) Directory.CreateDirectory(outputPath); } - // 获取源目录下所有一级子目录,建立小写->原始名映射 - var sourceDirs = Directory.Exists(deploymentPath) + // Get all top-level subdirectories and create lowercase-to-original mapping + var sourceDirectories = Directory.Exists(deploymentPath) ? Directory.GetDirectories(deploymentPath, "*", SearchOption.TopDirectoryOnly) : new string[0]; - var sourceDirMap = sourceDirs.ToDictionary( - d => Path.GetFileName(d).ToLowerInvariant(), - d => Path.GetFileName(d)); + var sourceDirectoryMap = sourceDirectories.ToDictionary( + directoryPath => Path.GetFileName(directoryPath).ToLowerInvariant(), + directoryPath => Path.GetFileName(directoryPath)); foreach (var directory in _directories) { - // 查找实际存在的目录名(忽略大小写) - if (sourceDirMap.TryGetValue(directory.ToLowerInvariant(), out var realDirName)) + // Find actual directory name (case-insensitive) + if (sourceDirectoryMap.TryGetValue(directory.ToLowerInvariant(), out var actualDirectoryName)) { CopyDirectory( - Path.Combine(deploymentPath, realDirName), - Path.Combine(outputPath, realDirName)); + Path.Combine(deploymentPath, actualDirectoryName), + Path.Combine(outputPath, actualDirectoryName)); } } foreach (var file in _files) { - var srcFile = Path.Combine(deploymentPath, file); - if (File.Exists(srcFile)) + var sourceFile = Path.Combine(deploymentPath, file); + if (File.Exists(sourceFile)) { - File.Copy(srcFile, Path.Combine(outputPath, file)); + File.Copy(sourceFile, Path.Combine(outputPath, file)); } }