static private void ConsoleUnpack(string[] args) { if (args.Length == 2 && File.Exists(args[1])) { if (SARC.Extract(args[1], Path.GetDirectoryName(args[1]) + "\\" + Path.GetFileNameWithoutExtension(args[1]))) { Console.WriteLine("Unpack Successful"); } else { Console.WriteLine("Unpack error: " + SARC.lerror); } } else if (args.Length == 3 && File.Exists(args[1])) { if (SARC.Extract(args[1], args[2])) { Console.WriteLine("Unpack Successful"); } else { Console.WriteLine("Unpack error: " + SARC.lerror); } } else { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Error: Incorrect use of Unpack command."); Console.WriteLine("/u <Input File> [Output Folder]"); Console.ForegroundColor = ConsoleColor.White; } }
private void btnExtractPack_Click(object sender, EventArgs e) //Extract Pack button { loadingBar.Visible = true; OpenFileDialog oFile = new OpenFileDialog(); if (tbxFolderRoot.Text != "") { oFile.InitialDirectory = tbxFolderRoot.Text; } if (oFile.ShowDialog() == DialogResult.Cancel) { goto toss; } String oFolderName = Path.GetFileNameWithoutExtension(oFile.FileName); String oFolderPath = Path.GetDirectoryName(oFile.FileName) + "\\" + oFolderName; // if the output folder exists, prompt user if they want to extract anyway if (Directory.Exists(oFolderPath)) { if (MessageBox.Show(oFolderName + " already exists!" + "\n\n" + "Proceed anyway?", "Overwrite?", MessageBoxButtons.YesNo) == DialogResult.No) { goto xml; } } //SARC bool boolAutoDecode = false; bool boolNodeDecode = false; if (cbxNodeDecode.Checked) //Node Yaz0 decoding { boolNodeDecode = true; } else //Default, without any checkboxes { if (SARC.IsYaz0File(oFile.FileName)) { if (MessageBox.Show("This file is Yaz0 encoded!" + "\n\n" + "Want to decode it and attempt to extract?", "Decode and Extact?", MessageBoxButtons.YesNo) != DialogResult.No) { boolAutoDecode = true; //Auto decode just this once since we prompted } else { goto toss; //User clicked no } } } if (!SARC.Extract(oFile.FileName, oFolderPath, boolAutoDecode, boolNodeDecode)) //Extraction { MessageBox.Show("Extraction error:" + "\n\n" + SARC.lerror); goto toss; } else { System.Diagnostics.Process.Start(oFolderPath); } //XML xml: if (cbxWriteSarcXml.Checked) { if (File.Exists(oFolderPath + "_SarcDebug.xml")) { if (MessageBox.Show(oFolderName + ".xml already exists!" + "\n\n" + "Proceed anyway?", "Overwrite?", MessageBoxButtons.YesNo) == DialogResult.No) { goto toss; } } if (!DebugWriter.WriteSarcXml(oFile.FileName, (oFolderPath + "_SarcDebug.xml"))) { MessageBox.Show("XML file failed to write by unknown reasons"); } } toss: oFile.Dispose(); GC.Collect(); loadingBar.Visible = false; }
private void btnExtractAll_Click(object sender, EventArgs e) { if (tbxFolderRoot.Text == "") { MessageBox.Show("Browse for a default folder to unpack from first!"); goto toss; } if (!(Directory.Exists(tbxFolderRoot.Text))) { MessageBox.Show("Error: Invalid path" + "\n" + tbxFolderRoot.Text); goto toss; } loadingBar.Visible = true; if (cbxCompileAllInOneFolder.Checked) { if (MessageBox.Show("Extract all SARC data type files from default path?" + "\n" + tbxFolderRoot.Text + "\n" + "*This does not include subfolders" + "\n\n" + "You are choosing to compile all extracted data to ONE folder!" + "\n" + "You'll then select a folder where you want to place them all in.", "Are you sure?", MessageBoxButtons.YesNo) == DialogResult.No) { goto toss; } } else { if (MessageBox.Show("Extract all SARC data type files from default path?" + "\n" + tbxFolderRoot.Text + "\n" + "*This does not include subfolders" + "\n\n" + "This will generate SEPERATE folders of every file it unpacks!", "Are you sure?", MessageBoxButtons.YesNo) == DialogResult.No) { goto toss; } } DirectoryInfo dirFolder = new DirectoryInfo(tbxFolderRoot.Text); String oFolderName, oFolderPath; int sarcFileCount = 0; bool boolAutoDecode = false; bool boolNodeDecode = false; if (cbxNodeDecode.Checked) //Auto Yaz0 decoding { boolNodeDecode = true; } if (cbxCompileAllInOneFolder.Checked) //Compile All to New Folder { CommonOpenFileDialog oFolder = new CommonOpenFileDialog(); oFolder.IsFolderPicker = true; if (tbxFolderRoot.Text != "") { oFolder.InitialDirectory = tbxFolderRoot.Text; } if (oFolder.ShowDialog() == CommonFileDialogResult.Cancel) { goto toss; } foreach (FileInfo file in dirFolder.GetFiles()) //Extraction { oFolderName = Path.GetFileNameWithoutExtension(file.FullName); oFolderPath = oFolder.FileName; if (SARC.Extract(file.FullName, oFolderPath, boolAutoDecode, boolNodeDecode)) { sarcFileCount++; } } } else { foreach (FileInfo file in dirFolder.GetFiles()) //Extraction { oFolderName = Path.GetFileNameWithoutExtension(file.FullName); oFolderPath = Path.GetDirectoryName(file.FullName) + "\\" + oFolderName; if (SARC.Extract(file.FullName, oFolderPath, boolAutoDecode, boolNodeDecode)) { sarcFileCount++; } } } MessageBox.Show("Done" + "\n\n" + sarcFileCount + " file(s) extracted!"); toss: GC.Collect(); loadingBar.Visible = false; }