Merge pull request #30 from ZestyTS/NDS-Zip

NDS and Zip
This commit is contained in:
ZestyTS 2022-07-05 00:11:38 -07:00 committed by GitHub
commit d6f044a84e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2379,44 +2379,29 @@ namespace UWUVCI_AIO_WPF
{
string RomName = string.Empty;
using (Process getRomName = new Process())
{
mvvm.msg = "Getting BaseRom Name...";
getRomName.StartInfo.UseShellExecute = false;
getRomName.StartInfo.CreateNoWindow = false;
getRomName.StartInfo.RedirectStandardOutput = true;
getRomName.StartInfo.FileName = "cmd.exe";
Console.WriteLine(Directory.GetCurrentDirectory());
//getRomName.StartInfo.Arguments = $"/c \"Tools\\7za.exe\" l \"temp\\baserom\\content\\0010\\rom.zip\" | findstr \"WUP\"";
getRomName.StartInfo.Arguments = "/c bin\\Tools\\7za.exe l bin\\temp\\baserom\\content\\0010\\rom.zip | findstr WUP";
getRomName.Start();
getRomName.WaitForExit();
var s = getRomName.StandardOutput.ReadToEnd();
var split = s.Split(' ');
RomName = split[split.Length - 1].Replace("\r\n", "");
mvvm.Progress = 15;
}
using (Process RomEdit = new Process())
{
mvvm.msg = "Removing BaseRom...";
RomEdit.StartInfo.UseShellExecute = false;
RomEdit.StartInfo.CreateNoWindow = true;
RomEdit.StartInfo.RedirectStandardOutput = true;
RomEdit.StartInfo.FileName = Path.Combine(toolsPath, "7za.exe");
//d Path.Combine(baseRomPath, "content", "0010", "rom.zip")
RomEdit.StartInfo.Arguments = $"d bin\\temp\\baserom\\content\\0010\\rom.zip";
RomEdit.Start();
RomEdit.WaitForExit();
mvvm.Progress = 40;
mvvm.msg = "Injecting ROM...";
File.Copy(injectRomPath, $"{RomName}");
RomEdit.StartInfo.Arguments = $"u bin\\temp\\baserom\\content\\0010\\rom.zip {RomName}";
RomEdit.Start();
RomEdit.WaitForExit();
mvvm.Progress = 80;
}
File.Delete(RomName);
mvvm.msg = "Getting BaseRom Name...";
var zipLocation = Path.Combine(baseRomPath, "content", "0010", "rom.zip");
using (var zip = ZipFile.Open(zipLocation, ZipArchiveMode.Read))
foreach (var file in zip.Entries)
if (file.Name.Contains("WUP"))
{
RomName = file.Name;
break;
}
mvvm.Progress = 15;
var romPath = Directory.GetCurrentDirectory() + "\\" + RomName;
mvvm.msg = "Removing BaseRom...";
File.Delete(romPath);
File.Delete(zipLocation);
File.Copy(injectRomPath, romPath);
using (var stream = new FileStream(zipLocation, FileMode.Create))
using (var archive = new ZipArchive(stream, ZipArchiveMode.Create))
archive.CreateEntryFromFile(romPath, Path.GetFileNameWithoutExtension(romPath));
mvvm.Progress = 80;
File.Delete(RomName);
}