Esempio n. 1
0
 static private void ConsoleBuildSwitch(string[] args)
 {
     if (args.Length == 2 && Directory.Exists(args[1]))
     {
         if (SARC.Build(args[1], args[1].Remove(args[1].LastIndexOf("\\")) + "\\" + Path.GetFileName(args[1]) + ".pack", true))
         {
             Console.WriteLine("Build Successful");
         }
         else
         {
             Console.WriteLine("Build error: " + SARC.lerror);
         }
     }
     else if (args.Length == 3 && Directory.Exists(args[1]))
     {
         if (SARC.Build(args[1], args[2], true))
         {
             Console.WriteLine("Build Successful");
         }
         else
         {
             Console.WriteLine("Build error: " + SARC.lerror);
         }
     }
     else
     {
         Console.ForegroundColor = ConsoleColor.Red;
         Console.WriteLine("Error: Incorrect use of Build command.");
         Console.WriteLine("/bs <Input Folder> [Output File]");
         Console.ForegroundColor = ConsoleColor.White;
     }
 }
Esempio n. 2
0
        private void btnBuildPack_Click(object sender, EventArgs e) // Build Pack button
        {
            CommonOpenFileDialog oFolder = new CommonOpenFileDialog();

            oFolder.IsFolderPicker = true;
            SaveFileDialog sFile = new SaveFileDialog();

            if (cbxSetDataOffset.Checked)
            {
                try{ int.Parse(tbxDataOffset.Text, System.Globalization.NumberStyles.HexNumber); } //check if it's a hex value (textbox limited to 4 characters)
                catch { MessageBox.Show("Error:" + "\n\n" + "Fixed Data Offset is not a hex value!"); goto toss; }
            }
            if (tbxFolderRoot.Text != "")
            {
                oFolder.InitialDirectory = tbxFolderRoot.Text;
            }
            if (oFolder.ShowDialog() == CommonFileDialogResult.Cancel)
            {
                goto toss;
            }
            int numFiles = Directory.GetFiles(oFolder.FileName, "*", SearchOption.AllDirectories).Length;

            sFile.Filter           = "All Files|*.*";
            sFile.InitialDirectory = oFolder.FileName.Remove(oFolder.FileName.LastIndexOf("\\")); //Previous folder, as selected is to build outside of it.
            sFile.FileName         = System.IO.Path.GetFileName(oFolder.FileName);
            loadingBar.Visible     = true;
            if (sFile.ShowDialog() == DialogResult.Cancel)
            {
                goto toss;
            }

            if (cbxSetDataOffset.Checked)
            {
                uint dataOffset = (uint)int.Parse(tbxDataOffset.Text, System.Globalization.NumberStyles.HexNumber);
                if (!SARC.Build(oFolder.FileName, sFile.FileName, dataOffset))
                {
                    MessageBox.Show("Failed to build!" + "\n\n" + SARC.lerror);
                    goto toss;
                }
            }
            else
            {
                if (!SARC.Build(oFolder.FileName, sFile.FileName))
                {
                    MessageBox.Show("Failed to build!" + "\n\n" + SARC.lerror);
                    goto toss;
                }
            }

            MessageBox.Show("Building Complete!" + "\n\n" + sFile.FileName);

toss:
            oFolder.Dispose();
            sFile.Dispose();
            GC.Collect();
            loadingBar.Visible = false;
        }