private void btnExtractPack_Click(object sender, EventArgs e) //Extract Pack button { OpenFileDialog oFile = new OpenFileDialog(); oFile.Filter = "PACK File (*.pack *.sarc *.ssarc *.rarc *.sgenvb *.sbfarc *.sblarc *.sbactorpack)|*.pack; *.sarc; *.ssarc; *.rarc; *.sgenvb; *.sbfarc; *.sblarc; *.sbactorpack|All Files|*.*"; 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 lblProcessStatus.Visible = true; bool boolAutoDecode = false; bool boolReplaceFile = false; if (cbxAutoDecode.Checked) //Auto Yaz0 decoding { boolAutoDecode = true; if (cbxReplaceDecodedFile.Checked) //Replace File { boolReplaceFile = true; } } if (!PACK.Extract(oFile.FileName, oFolderPath, boolAutoDecode, boolReplaceFile)) //Extraction { MessageBox.Show("Extraction error:" + "\n\n" + PACK.lerror); goto toss; } else { System.Diagnostics.Process.Start(oFolderPath); } //XML xml: if (cbxWriteXml.Checked) { if (File.Exists(oFolderPath + ".xml")) { if (MessageBox.Show(oFolderName + ".xml already exists!" + "\n\n" + "Proceed anyway?", "Overwrite?", MessageBoxButtons.YesNo) == DialogResult.No) { goto toss; } } if (!XMLWriter.SaveXml(oFile.FileName, (oFolderPath + ".xml"))) { MessageBox.Show("XML file failed to write by unknown reasons"); } } toss: oFile.Dispose(); GC.Collect(); lblProcessStatus.Visible = false; }
private void btnExtractAll_Click(object sender, EventArgs e) { if (!(Directory.Exists(tbxFolderRoot.Text))) { MessageBox.Show("Error: Invalid path" + "\n" + tbxFolderRoot.Text); goto toss; } if (cbxCompileAllInOneFolder.Checked) { if (MessageBox.Show("Extract all SARC data type files from default path?" + "\n" + tbxFolderRoot.Text + "\n\n" + "You are choosing to compile all extracted data to one folder!" + "\n" + "This does not include subfolders", "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\n" + "This will generate seperate folders of every file it unpacks" + "\n" + "This does not include subfolders", "Are you sure?", MessageBoxButtons.YesNo) == DialogResult.No) { goto toss; } } lblProcessStatus.Visible = true; DirectoryInfo dirFolder = new DirectoryInfo(tbxFolderRoot.Text); String oFolderName, oFolderPath; int sarcFileCount = 0; bool boolAutoDecode = false; bool boolReplaceFile = false; if (cbxAutoDecode.Checked) //Auto Yaz0 decoding { boolAutoDecode = true; if (cbxReplaceDecodedFile.Checked) //Replace File { boolReplaceFile = true; } } if (cbxCompileAllInOneFolder.Checked) //Compile All to New Folder { FolderBrowserDialog oFolder = new FolderBrowserDialog(); if (tbxFolderRoot.Text != "") { oFolder.SelectedPath = tbxFolderRoot.Text; } if (oFolder.ShowDialog() == DialogResult.Cancel) { goto toss; } foreach (FileInfo file in dirFolder.GetFiles()) //Extraction { oFolderName = Path.GetFileNameWithoutExtension(file.FullName); oFolderPath = oFolder.SelectedPath; if (PACK.Extract(file.FullName, oFolderPath, boolAutoDecode, boolReplaceFile)) { sarcFileCount++; } } } else { foreach (FileInfo file in dirFolder.GetFiles()) //Extraction { oFolderName = Path.GetFileNameWithoutExtension(file.FullName); oFolderPath = Path.GetDirectoryName(file.FullName) + "\\" + oFolderName; if (PACK.Extract(file.FullName, oFolderPath, boolAutoDecode, boolReplaceFile)) { sarcFileCount++; } } } MessageBox.Show("Done" + "\n\n" + sarcFileCount + " file(s) extracted!"); toss: GC.Collect(); lblProcessStatus.Visible = false; }