public static void Patch(string modDir) { ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.CreateNoWindow = true; startInfo.FileName = $@"{Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}\Dependencies\rdb_tool.exe"; if (!FileIOWrapper.Exists(startInfo.FileName)) { Console.WriteLine($"[ERROR] Couldn't find {startInfo.FileName}. Please check if it was blocked by your anti-virus."); return; } startInfo.WindowStyle = ProcessWindowStyle.Hidden; startInfo.RedirectStandardOutput = true; startInfo.UseShellExecute = false; foreach (var rdb in Directory.GetFiles(modDir, "*.rdb")) { startInfo.Arguments = $@"""{rdb}"" ""{rdb}"""; Console.WriteLine($"[INFO] Patching {rdb}..."); using (Process process = new Process()) { process.StartInfo = startInfo; process.Start(); while (!process.HasExited) { string text = process.StandardOutput.ReadLine(); if (text != "" && text != null) { Console.WriteLine($"[INFO] {text}"); } } } } }
private async void UnpackPacsClick(object sender, RoutedEventArgs e) { string directory; if (main.modPath != null && FileIOWrapper.Exists($@"{Directory.GetParent(main.modPath)}\data00004.pac")) { directory = Directory.GetParent(main.modPath).ToString(); } else { directory = openPacsFolder(); } if (directory != null) { if (FileIOWrapper.Exists($@"{directory}\{main.cpkLang}")) { UnpackButton.IsHitTestVisible = false; main.ModGrid.IsHitTestVisible = false; main.GameBox.IsHitTestVisible = false; foreach (var button in main.buttons) { button.Foreground = new SolidColorBrush(Colors.Gray); button.IsHitTestVisible = false; } await main.pacUnpack(directory); UnpackButton.IsHitTestVisible = true; } else { Console.WriteLine($"[ERROR] Invalid folder cannot find {main.cpkLang}"); } } }
public static void Merge(List <string> ModList, string modDir) { foreach (var mod in ModList) { if (!Directory.Exists(mod)) { Console.WriteLine($"[ERROR] Cannot find {mod}"); continue; } // Run prebuild.bat if (FileIOWrapper.Exists($@"{mod}\prebuild.bat") && new FileInfo($@"{mod}\prebuild.bat").Length > 0) { Console.WriteLine($@"[INFO] Running {mod}\prebuild.bat..."); ProcessStartInfo ProcessInfo; ProcessInfo = new ProcessStartInfo(); ProcessInfo.FileName = Path.GetFullPath($@"{mod}\prebuild.bat"); ProcessInfo.CreateNoWindow = true; ProcessInfo.UseShellExecute = false; ProcessInfo.WorkingDirectory = Path.GetFullPath(mod); using (Process process = new Process()) { process.StartInfo = ProcessInfo; process.Start(); process.WaitForExit(); } Console.WriteLine($@"[INFO] Finished running {mod}\prebuild.bat!"); } if (!Directory.Exists($@"{mod}\data")) { Console.WriteLine($"[WARNING] No data folder found in {mod}, skipping..."); continue; } // Copy over .files, hashing them when neccessary foreach (var file in Directory.GetFiles($@"{mod}\data", "*", SearchOption.AllDirectories)) { string fileName = Path.GetFileName(file); if (Path.GetExtension(file).ToLower() != ".file") { fileName = Hash(Path.GetFileName(file)); } Console.WriteLine($@"[INFO] Copying over {file} to {modDir}\data\{fileName}"); try { FileIOWrapper.Copy(file, $@"{modDir}\data\{fileName.ToLower()}", true); } catch (Exception e) { Console.WriteLine($"[ERROR] Couldn't copy over {file} ({e.Message})"); } } } }
// P3F public static void Unzip(string iso) { if (!FileIOWrapper.Exists(iso)) { Console.Write($"[ERROR] Couldn't find {iso}. Please correct the file path in config."); return; } ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.CreateNoWindow = true; startInfo.FileName = $@"{Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}\Dependencies\7z\7z.exe"; if (!FileIOWrapper.Exists(startInfo.FileName)) { Console.Write($"[ERROR] Couldn't find {startInfo.FileName}. Please check if it was blocked by your anti-virus."); return; } Application.Current.Dispatcher.Invoke(() => { Mouse.OverrideCursor = Cursors.Wait; }); startInfo.WindowStyle = ProcessWindowStyle.Hidden; startInfo.UseShellExecute = false; startInfo.Arguments = $"x -y \"{iso}\" -o\"" + @"Original\Persona 3 FES" + "\" BTL.CVM DATA.CVM"; Console.WriteLine($"[INFO] Extracting BTL.CVM and DATA.CVM from {iso}"); using (Process process = new Process()) { process.StartInfo = startInfo; process.Start(); process.WaitForExit(); } startInfo.Arguments = "x -y \"" + $@"{Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}\Original\Persona 3 FES\BTL.CVM" + "\" -o\"" + $@"{Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}\Original\Persona 3 FES\BTL" + "\" *.BIN *.PAK *.PAC *.TBL *.SPR -r"; Console.WriteLine($"[INFO] Extracting base files from BTL.CVM"); using (Process process = new Process()) { process.StartInfo = startInfo; process.Start(); process.WaitForExit(); } FileIOWrapper.Delete($@"{Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}\Original\Persona 3 FES\BTL.CVM"); startInfo.Arguments = "x -y \"" + $@"{Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}\Original\Persona 3 FES\DATA.CVM" + "\" -o\"" + $@"{Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}\Original\Persona 3 FES\DATA" + "\" *.BIN *.PAK *.PAC *.SPR -r"; Console.WriteLine($"[INFO] Extracting base files from DATA.CVM"); using (Process process = new Process()) { process.StartInfo = startInfo; process.Start(); process.WaitForExit(); } FileIOWrapper.Delete($@"{Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}\Original\Persona 3 FES\DATA.CVM"); Console.WriteLine($"[INFO] Finished unpacking base files!"); Application.Current.Dispatcher.Invoke(() => { Mouse.OverrideCursor = null; }); }
private static int findTmx(string spr, string tmxName) { // Get all tmx names instead to prevent replacing similar names if (FileIOWrapper.Exists(spr)) { Dictionary <string, int> tmxNames = getTmxNames(spr); if (tmxNames.ContainsKey(tmxName)) { return(tmxNames[tmxName]); } } return(-1); }
private async Task DownloadFile(string uri, string fileName, string game, DisplayedMetadata row, string version, Progress <DownloadProgress> progress, CancellationTokenSource cancellationToken, GameBananaItemUpdate update = null) { try { // Create the downloads folder if necessary if (!Directory.Exists($@"{assemblyLocation}\Downloads")) { Directory.CreateDirectory($@"{assemblyLocation}\Downloads"); } // Download the file if it doesn't already exist if (!FileIOWrapper.Exists($@"{assemblyLocation}\Downloads\{fileName}")) { progressBox = new UpdateProgressBox(cancellationToken); progressBox.progressBar.Value = 0; progressBox.progressText.Text = $"Downloading {fileName}"; progressBox.finished = false; progressBox.Title = $"{row.name} Update Progress"; progressBox.Show(); progressBox.Activate(); Console.WriteLine($"[INFO] Downloading {fileName}"); // Write and download the file using (var fs = new FileStream( $@"{assemblyLocation}\Downloads\{fileName}", System.IO.FileMode.Create, FileAccess.Write, FileShare.None)) { await client.DownloadAsync(uri, fs, fileName, progress, cancellationToken.Token); } Console.WriteLine($"[INFO] Finished downloading {fileName}"); progressBox.Close(); } else { Console.WriteLine($"[INFO] {fileName} already exists in downloads, using this instead"); } ExtractFile(fileName, game, row, version, update); } catch (OperationCanceledException) { // Remove the file is it will be a partially downloaded one and close up FileIOWrapper.Delete(@$ "Downloads\{fileName}"); if (progressBox != null) { progressBox.finished = true; progressBox.Close(); } return; }
public static void Backup(string modPath) { Directory.CreateDirectory($@"{Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}\Original\Persona 5 Strikers\motor_rsc\data"); foreach (var file in original_data) { Console.WriteLine($@"[INFO] Backing up {modPath}\data\{file}"); if (FileIOWrapper.Exists($@"{modPath}\data\{file}")) { FileIOWrapper.Copy($@"{modPath}\data\{file}", $@"{Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}\Original\Persona 5 Strikers\motor_rsc\data\{file}", true); } else { Console.WriteLine($@"[ERROR] Couldn't find {modPath}\data\{file}"); } } foreach (var rdb in Directory.GetFiles(modPath, "*.rdb")) { Console.WriteLine($"[INFO] Backing up {rdb}"); FileIOWrapper.Copy(rdb, $@"{Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}\Original\Persona 5 Strikers\motor_rsc\{Path.GetFileName(rdb)}", true); } }
public async Task ExtractPackageAsync(string sourceFilePath, string destDirPath, IProgress <double>?progress = null, CancellationToken cancellationToken = default) { ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.CreateNoWindow = true; startInfo.FileName = @$ "{Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}\Dependencies\7z\7z.exe"; if (!FileIOWrapper.Exists(startInfo.FileName)) { Console.WriteLine($"[ERROR] Couldn't find {startInfo.FileName}. Please check if it was blocked by your anti-virus."); return; } // Extract the file startInfo.Arguments = $"x -y \"{sourceFilePath}\" -o\"{destDirPath}\""; Console.WriteLine($"[INFO] Extracting {sourceFilePath}"); startInfo.WindowStyle = ProcessWindowStyle.Hidden; startInfo.UseShellExecute = false; using (Process process = new Process()) { process.StartInfo = startInfo; process.Start(); process.WaitForExit(); } // TODO Check if it actually succeeded (by reading the command output I guess) Console.WriteLine($"[INFO] Done Extracting {sourceFilePath}"); FileIOWrapper.Delete(@$ "{sourceFilePath}"); Console.WriteLine(@$ "[INFO] Deleted {sourceFilePath}"); // Move the folders to the right place string parentPath = Directory.GetParent(destDirPath).FullName; Directory.Move(Directory.GetDirectories(destDirPath)[0], $@"{parentPath}\Aemulus"); Directory.Delete(destDirPath); Directory.Move($@"{parentPath}\Aemulus", destDirPath); }
// P4G public static void Unpack(string directory, string cpk) { Directory.CreateDirectory($@"{Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}\Original\Persona 4 Golden"); if (!Directory.Exists(directory)) { Console.WriteLine($"[ERROR] Couldn't find {directory}. Please correct the file path in config."); return; } List <string> pacs = new List <string>(); List <string> globs = new List <string> { "*[!0-9].bin", "*2[0-1][0-9].bin", "*.arc", "*.pac", "*.pack" }; switch (cpk) { case "data_e.cpk": pacs.Add("data00004.pac"); pacs.Add("data_e.cpk"); break; case "data.cpk": pacs.Add("data00000.pac"); pacs.Add("data00001.pac"); pacs.Add("data00003.pac"); pacs.Add("data.cpk"); break; case "data_k.cpk": pacs.Add("data00005.pac"); pacs.Add("data_k.cpk"); break; case "data_c.cpk": pacs.Add("data00006.pac"); pacs.Add("data_c.cpk"); break; } ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.CreateNoWindow = true; startInfo.FileName = $@"{Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}\Dependencies\Preappfile\preappfile.exe"; if (!FileIOWrapper.Exists(startInfo.FileName)) { Console.WriteLine($"[ERROR] Couldn't find {startInfo.FileName}. Please check if it was blocked by your anti-virus."); return; } Application.Current.Dispatcher.Invoke(() => { Mouse.OverrideCursor = Cursors.Wait; }); startInfo.WindowStyle = ProcessWindowStyle.Hidden; startInfo.RedirectStandardOutput = true; startInfo.UseShellExecute = false; foreach (var pac in pacs) { Console.WriteLine($"[INFO] Unpacking files for {pac}..."); foreach (var glob in globs) { startInfo.Arguments = $@"-i ""{directory}\{pac}"" -o ""{Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}\Original\Persona 4 Golden\{Path.GetFileNameWithoutExtension(pac)}"" --unpack-filter {glob}"; using (Process process = new Process()) { process.StartInfo = startInfo; process.Start(); while (!process.HasExited) { string text = process.StandardOutput.ReadLine(); if (text != "" && text != null) { Console.WriteLine($"[INFO] {text}"); } } } } } if (FileIOWrapper.Exists($@"{directory}\{cpk}") && !FileIOWrapper.Exists($@"{Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}\Original\Persona 4 Golden\{cpk}")) { Console.WriteLine($@"[INFO] Backing up {cpk}"); FileIOWrapper.Copy($@"{directory}\{cpk}", $@"{Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}\Original\Persona 4 Golden\{cpk}", true); } if (FileIOWrapper.Exists($@"{directory}\movie.cpk") && !FileIOWrapper.Exists($@"{Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}\Original\Persona 4 Golden\movie.cpk")) { Console.WriteLine($@"[INFO] Backing up movie.cpk"); FileIOWrapper.Copy($@"{directory}\movie.cpk", $@"{Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}\Original\Persona 4 Golden\movie.cpk", true); } Console.WriteLine("[INFO] Finished unpacking base files!"); Application.Current.Dispatcher.Invoke(() => { Mouse.OverrideCursor = null; }); }
public static void UnpackCPK(string directory) { if (!Directory.Exists(directory)) { Console.WriteLine($"[ERROR] Couldn't find {directory}. Please correct the file path in config."); return; } Application.Current.Dispatcher.Invoke(() => { Mouse.OverrideCursor = Cursors.Wait; }); if (FileIOWrapper.Exists($@"{directory}\ps3.cpk.66600") && FileIOWrapper.Exists($@"{directory}\ps3.cpk.66601") && FileIOWrapper.Exists($@"{directory}\ps3.cpk.66602") && !FileIOWrapper.Exists($@"{directory}\ps3.cpk")) { Console.Write("[INFO] Combining ps3.cpk parts"); ProcessStartInfo cmdInfo = new ProcessStartInfo(); cmdInfo.CreateNoWindow = true; cmdInfo.FileName = @"CMD.exe"; cmdInfo.WindowStyle = ProcessWindowStyle.Hidden; cmdInfo.Arguments = $@"/C copy /b ""{directory}\ps3.cpk.66600"" + ""{directory}\ps3.cpk.66601"" + ""{directory}\ps3.cpk.66602"" ""{directory}\ps3.cpk"""; using (Process process = new Process()) { process.StartInfo = cmdInfo; process.Start(); process.WaitForExit(); } } Directory.CreateDirectory($@"{Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}\Original\Persona 5"); if (!FileIOWrapper.Exists($@"{Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}\Dependencies\MakeCpk\filtered_data.csv") || !FileIOWrapper.Exists($@"{Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}\Dependencies\MakeCpk\filtered_ps3.csv")) { Console.WriteLine($@"[ERROR] Couldn't find CSV files used for unpacking in Dependencies\MakeCpk"); Application.Current.Dispatcher.Invoke(() => { Mouse.OverrideCursor = null; }); return; } string[] dataFiles = FileIOWrapper.ReadAllLines($@"{Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}\Dependencies\MakeCpk\filtered_data.csv"); string[] ps3Files = FileIOWrapper.ReadAllLines($@"{Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}\Dependencies\MakeCpk\filtered_ps3.csv"); ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.CreateNoWindow = true; startInfo.FileName = $@"{Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}\Dependencies\MakeCpk\YACpkTool.exe"; if (!FileIOWrapper.Exists(startInfo.FileName)) { Console.WriteLine($"[ERROR] Couldn't find {startInfo.FileName}. Please check if it was blocked by your anti-virus."); Application.Current.Dispatcher.Invoke(() => { Mouse.OverrideCursor = null; }); return; } startInfo.WindowStyle = ProcessWindowStyle.Hidden; startInfo.RedirectStandardOutput = true; startInfo.UseShellExecute = false; if (FileIOWrapper.Exists($@"{directory}\data.cpk")) { Console.WriteLine($"[INFO] Extracting data.cpk"); foreach (var file in dataFiles) { startInfo.Arguments = $@"-X {file} -i ""{directory}\data.cpk"" -o ""{Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}\Original\Persona 5"""; using (Process process = new Process()) { process.StartInfo = startInfo; process.Start(); while (!process.HasExited) { string text = process.StandardOutput.ReadLine(); if (text != "" && text != null) { Console.WriteLine($"[INFO] {text}"); } } } } } else { Console.WriteLine($"[ERROR] Couldn't find data.cpk in {directory}."); } if (FileIOWrapper.Exists($@"{directory}\data.cpk")) { Console.WriteLine($"[INFO] Extracting ps3.cpk"); foreach (var file in ps3Files) { startInfo.Arguments = $@"-X {file} -i ""{directory}\ps3.cpk"" -o ""{Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}\Original\Persona 5"""; using (Process process = new Process()) { process.StartInfo = startInfo; process.Start(); while (!process.HasExited) { string text = process.StandardOutput.ReadLine(); if (text != "" && text != null) { Console.WriteLine($"[INFO] {text}"); } } } } } else { Console.WriteLine($"[ERROR] Couldn't find ps3.cpk in {directory}."); } Console.WriteLine($"[INFO] Finished unpacking base files!"); Application.Current.Dispatcher.Invoke(() => { Mouse.OverrideCursor = null; }); }
public static void Validate(string path, string cpkLang) { var validated = true; ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.CreateNoWindow = true; startInfo.FileName = $@"{Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}\Dependencies\Preappfile\preappfile.exe"; startInfo.WindowStyle = ProcessWindowStyle.Hidden; startInfo.UseShellExecute = false; startInfo.RedirectStandardOutput = true; if (FileIOWrapper.Exists($@"{path}\data00007.pac")) { startInfo.Arguments = $@"""{path}\data00007.pac"""; using (Process process = new Process()) { process.StartInfo = startInfo; process.Start(); process.WaitForExit(); } foreach (var file in Directory.GetFiles($@"{path}\mods\preappfile\{Path.GetFileNameWithoutExtension(cpkLang)}", "*", SearchOption.AllDirectories)) { var folders = new List <string>(file.Split(char.Parse("\\"))); int idx = folders.IndexOf(Path.GetFileNameWithoutExtension(cpkLang)); if (File.Exists($@"{path}\data00007\{string.Join("\\", folders.Skip(idx + 1).ToArray())}")) { Console.WriteLine($"[INFO] Validated that {file} was appended"); } else { Console.WriteLine($"[WARNING] {file} not appended"); validated = false; } } if (Directory.Exists($@"{path}\data00007")) { Directory.Delete($@"{path}\data00007", true); } } if (FileIOWrapper.Exists($@"{path}\movie00003.pac")) { startInfo.Arguments = $@"""{path}\movie00003.pac"""; using (Process process = new Process()) { process.StartInfo = startInfo; process.Start(); process.WaitForExit(); } foreach (var file in Directory.GetFiles($@"{path}\mods\preappfile\movie", "*", SearchOption.AllDirectories)) { var folders = new List <string>(file.Split(char.Parse("\\"))); int idx = folders.IndexOf("movie00003"); if (File.Exists($@"{path}\movie00003\{string.Join("\\", folders.Skip(idx + 1).ToArray())}")) { Console.WriteLine($"[INFO] Validated appended {file}"); } else { Console.WriteLine($"[Warning] {file} not appended"); validated = false; } } if (Directory.Exists($@"{path}\movie00003")) { Directory.Delete($@"{path}\movie00003", true); } } if (!validated) { Console.WriteLine($"[WARNING] Not all appended files were validated, trying again"); Append(path, cpkLang); Validate(path, cpkLang); } }
public static void Append(string path, string cpkLang) { // Check if required files are there if (!FileIOWrapper.Exists($@"{Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}\Dependencies\preappfile\preappfile.exe")) { Console.WriteLine($@"[ERROR] Couldn't find Dependencies\preappfile\preappfile.exe. Please check if it was blocked by your anti-virus."); return; } if (!FileIOWrapper.Exists($@"{path}\{cpkLang}")) { Console.WriteLine($@"[ERROR] Couldn't find {path}\{cpkLang} for appending."); return; } // Backup cpk if not backed up already if (!FileIOWrapper.Exists($@"{Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}\Original\Persona 4 Golden\{cpkLang}")) { Console.WriteLine($@"[INFO] Backing up {cpkLang}.cpk"); FileIOWrapper.Copy($@"{path}\{cpkLang}", $@"Original\Persona 4 Golden\{cpkLang}"); } // Copy original cpk back if different if (GetChecksumString($@"{Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}\Original\Persona 4 Golden\{cpkLang}") != GetChecksumString($@"{path}\{cpkLang}")) { Console.WriteLine($@"[INFO] Reverting {cpkLang} back to original"); FileIOWrapper.Copy($@"{Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}\Original\Persona 4 Golden\{cpkLang}", $@"{path}\{cpkLang}", true); } if (!FileIOWrapper.Exists($@"{Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}\Original\Persona 4 Golden\movie.cpk")) { Console.WriteLine($@"[INFO] Backing up movie.cpk"); FileIOWrapper.Copy($@"{path}\movie.cpk", $@"{Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}\Original\Persona 4 Golden\movie.cpk"); } // Copy original cpk back if different if (GetChecksumString($@"{Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}\Original\Persona 4 Golden\movie.cpk") != GetChecksumString($@"{path}\movie.cpk")) { Console.WriteLine($@"[INFO] Reverting movie.cpk back to original"); FileIOWrapper.Copy($@"{Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}\Original\Persona 4 Golden\movie.cpk", $@"{path}\movie.cpk", true); } // Delete modified pacs if (FileIOWrapper.Exists($@"{path}\data00007.pac")) { Console.WriteLine($"[INFO] Deleting data00007.pac"); FileIOWrapper.Delete($@"{path}\data00007.pac"); } if (FileIOWrapper.Exists($@"{path}\movie00003.pac")) { Console.WriteLine($"[INFO] Deleting movie00003.pac"); FileIOWrapper.Delete($@"{path}\movie00003.pac"); } ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.CreateNoWindow = true; startInfo.FileName = $@"{Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}\Dependencies\Preappfile\preappfile.exe"; startInfo.WindowStyle = ProcessWindowStyle.Hidden; startInfo.UseShellExecute = false; if (Directory.Exists($@"{path}\mods\preappfile\{Path.GetFileNameWithoutExtension(cpkLang)}")) { Console.WriteLine($@"[INFO] Appending to {cpkLang}"); startInfo.Arguments = $@"-i ""{path}\mods\preappfile\{Path.GetFileNameWithoutExtension(cpkLang)}"" -a ""{path}\{cpkLang}"" -o ""{path}\{cpkLang}"" --pac-index 7"; using (Process process = new Process()) { process.StartInfo = startInfo; process.Start(); process.WaitForExit(); } } if (Directory.Exists($@"{path}\mods\preappfile\movie")) { Console.WriteLine($@"[INFO] Appending to movie"); startInfo.Arguments = $@"-i ""{path}\mods\preappfile\movie"" -a ""{path}\movie.cpk"" -o ""{path}\movie.cpk"" --pac-index 3"; using (Process process = new Process()) { process.StartInfo = startInfo; process.Start(); process.WaitForExit(); } } }
public static void Restart(string modPath) { Console.WriteLine($"[INFO] Restoring directory to original state..."); // Just in case its missing for some reason Directory.CreateDirectory($@"{modPath}\data"); // Clear data directory Parallel.ForEach(Directory.GetFiles($@"{modPath}\data"), file => { // Delete if not found in Original if (!FileIOWrapper.Exists($@"{Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}\Original\Persona 5 Strikers\motor_rsc\data\{Path.GetFileName(file)}")) { Console.WriteLine($@"[INFO] Deleting {file}..."); try { FileIOWrapper.Delete(file); } catch (Exception e) { Console.WriteLine($"[ERROR] Couldn't delete {file} ({e.Message})"); } } // Overwrite if file size/date modified are different else if (new FileInfo(file).Length != new FileInfo($@"{Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}\Original\Persona 5 Strikers\motor_rsc\data\{Path.GetFileName(file)}").Length || FileIOWrapper.GetLastWriteTime(file) != FileIOWrapper.GetLastWriteTime($@"{Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}\Original\Persona 5 Strikers\motor_rsc\data\{Path.GetFileName(file)}")) { Console.WriteLine($@"[INFO] Reverting {file} to original..."); try { FileIOWrapper.Copy($@"{Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}\Original\Persona 5 Strikers\motor_rsc\data\{Path.GetFileName(file)}", file, true); } catch (Exception e) { Console.WriteLine($"[ERROR] Couldn't overwrite {file} ({e.Message})"); } } }); // Copy over original files that may have accidentally been deleted foreach (var file in original_data) { if (!FileIOWrapper.Exists($@"{modPath}\data\{file}") && FileIOWrapper.Exists($@"{Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}\Original\Persona 5 Strikers\motor_rsc\data\{file}")) { Console.WriteLine($"[INFO] Restoring {file}..."); try { FileIOWrapper.Copy($@"{Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}\Original\Persona 5 Strikers\motor_rsc\data\{file}", $@"{modPath}\data\{file}", true); } catch (Exception e) { Console.WriteLine($"[ERROR] Couldn't copy over {file} ({e.Message})"); } } } // Copy over backed up original rdbs foreach (var file in Directory.GetFiles(modPath, "*.rdb")) { Console.WriteLine($@"[INFO] Reverting {file} to original..."); try { FileIOWrapper.Copy($@"{Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}\Original\Persona 5 Strikers\motor_rsc\{Path.GetFileName(file)}", file, true); } catch (Exception e) { Console.WriteLine($"[ERROR] Couldn't overwrite {file} ({e.Message})"); } } }