Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions RPGMakerDecrypter.MVMZ/ProjectReconstructor.cs
Comment thread
Mabbs marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.IO;
using System.Linq;

namespace RPGMakerDecrypter.MVMZ
{
Expand All @@ -9,6 +10,7 @@ public abstract class ProjectReconstructor
"audio",
"css",
"data",
"dataex",

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you confirmed by yourself that there actually can be a directory with this name?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I found that many games have this directory

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you confirmed by yourself that there actually can be a directory with this name?

image

"effects",
"fonts",
"icon",
Expand All @@ -34,14 +36,32 @@ public virtual void Reconstruct(string deploymentPath, string outputPath)
Directory.CreateDirectory(outputPath);
}

// 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 sourceDirectoryMap = sourceDirectories.ToDictionary(
directoryPath => Path.GetFileName(directoryPath).ToLowerInvariant(),
directoryPath => Path.GetFileName(directoryPath));

foreach (var directory in _directories)
{
CopyDirectory(Path.Combine(deploymentPath, directory), Path.Combine(outputPath, directory));
// Find actual directory name (case-insensitive)
if (sourceDirectoryMap.TryGetValue(directory.ToLowerInvariant(), out var actualDirectoryName))
{
CopyDirectory(
Path.Combine(deploymentPath, actualDirectoryName),
Path.Combine(outputPath, actualDirectoryName));
}
}

foreach (var file in _files)
{
File.Copy(Path.Combine(deploymentPath, file), Path.Combine(outputPath, file));
var sourceFile = Path.Combine(deploymentPath, file);
if (File.Exists(sourceFile))
{
File.Copy(sourceFile, Path.Combine(outputPath, file));
}
}

CreateProjectFile(outputPath);
Expand Down Expand Up @@ -69,4 +89,4 @@ private void CopyDirectory(string sourceDir, string destinationDir)
}
}
}
}
}