public static void Main (string[] args) { if (args.Length == 0) { Console.WriteLine ("No file provided for extraction!"); return; } // load file BodFile file = new BodFile (); file.Load (args [0]); // extract int count = 0; foreach (BodEntry entry in file.Entries) { if (entry.Type == BodEntryType.File) { File.WriteAllBytes (entry.Name, ((BodFileEntry)entry).Data); count++; } } Console.WriteLine ("Successfully extracted " + count + " files"); }
/// <summary> /// Open a bod file. /// </summary> private void Open() { if (_changed) { DialogResult dr = MessageBox.Show ("Are you sure you want to discard your changes?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.No) return; } // open file dialog OpenFileDialog ofd = new OpenFileDialog (); ofd.Title = "Open Bod File"; ofd.Filter = "Bod File (*.bod)|*.bod|All files (*.*)|*.*"; if (ofd.ShowDialog () == DialogResult.OK) { try { // load _file = new BodFile(); _file.Load(ofd.FileName); // workspace _changed = false; _filename = ofd.FileName; } catch (UnauthorizedAccessException) { // unauthorized access Program.Error("Access denied, run as administrator!"); } catch (Exception) { // unknown exception Program.Error("File is corrupted, try reinstalling the source game"); } } // update stuff UpdateUI (); BuildTree (); }
/// <summary> /// Create a new bod file. /// </summary> private void New() { if (_changed) { DialogResult dr = MessageBox.Show ("Are you sure you want to discard your changes?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.No) return; } _file = new BodFile (); }