Exemplo n.º 1
0
        private void MakeUPSPatchButton_Click(object sender, EventArgs e)
        {
            if (InputFormRef.IsPleaseWaitDialog(this))
            {//2重割り込み禁止
                return;
            }

            string errorMessage = MainFormUtil.CheckOrignalROM(OrignalFilename.Text);

            if (errorMessage != "")
            {
                string error = R._("無改造ROMを指定してください。") + "\r\n" + errorMessage;
                OrignalFilename.ErrorMessage = error;
                R.ShowStopError(error);
                return;
            }
            OrignalFilename.ErrorMessage = "";

            string         title  = R._("作成するUPSファイル名を選択してください");
            string         filter = R._("UPS|*.ups|All files|*");
            SaveFileDialog save   = new SaveFileDialog();

            save.Title        = title;
            save.Filter       = filter;
            save.AddExtension = true;
            Program.LastSelectedFilename.Load(this, "", save, MakeUPSFilename());

            DialogResult dr = save.ShowDialog();

            if (dr != DialogResult.OK)
            {
                return;
            }
            if (save.FileNames.Length <= 0 || !U.CanWriteFileRetry(save.FileNames[0]))
            {
                return;
            }
            Program.LastSelectedFilename.Save(this, "", save);

            using (InputFormRef.AutoPleaseWait pleaseWait = new InputFormRef.AutoPleaseWait(this))
            {
                UPSUtil.MakeUPS(OrignalFilename.Text, save.FileName);
            }
            //エクスプローラで選択しよう
            U.SelectFileByExplorer(save.FileName);
        }
Exemplo n.º 2
0
        public static int CommandLineMakeUPS()
        {
            U.echo("CommandLineMakeUPS");

            ToolUPSPatchSimpleForm f = (ToolUPSPatchSimpleForm)InputFormRef.JumpFormLow <ToolUPSPatchSimpleForm>();

            f.OnLoad(new EventArgs());
            string fromrom = U.at(Program.ArgsDic, "--fromrom");

            if (fromrom == "")
            {
                fromrom = U.at(Program.ArgsDic, "--target");
            }
            if (fromrom != "")
            {
                f.OrignalFilename.Text = fromrom;
            }

            string errorMessage = MainFormUtil.CheckOrignalROM(f.OrignalFilename.Text);

            if (errorMessage != "")
            {
                string error = R._("無改造ROMを指定してください。") + "\r\n" + errorMessage;
                f.OrignalFilename.ErrorMessage = error;
                R.ShowStopError(error);
                return(-2);
            }

            string makeups = U.at(Program.ArgsDic, "--makeups");

            if (makeups == "")
            {
                U.echo("保存するファイル名を選択してください");
                return(-2);
            }

            using (InputFormRef.AutoPleaseWait pleaseWait = new InputFormRef.AutoPleaseWait(f))
            {
                UPSUtil.MakeUPS(f.OrignalFilename.Text, makeups);
            }
            //エクスプローラで選択しよう
            U.SelectFileByExplorer(makeups);

            return(0);
        }
Exemplo n.º 3
0
        bool MakeUPS(string tempdir, byte[] s, string targetFilename)
        {
            string filename_only = Path.GetFileName(targetFilename);

            if (filename_only.IndexOf(".backup.") <= -1)
            {
                return(false);
            }
            InputFormRef.DoEvents(this, "=>" + Path.GetFileName(targetFilename));

            string orignalFilename = OrignalFilename.Text;

            byte[] d   = MainFormUtil.OpenROMToByte(targetFilename, orignalFilename);
            string ups = Path.Combine(tempdir, Path.GetFileNameWithoutExtension(targetFilename) + ".ups");

            UPSUtil.MakeUPS(s, d, ups);
            U.CopyTimeStamp(targetFilename, ups); //タイムスタンプを元のファイルに合わせる.

            return(true);
        }
Exemplo n.º 4
0
        //現在のROMのUPSデータの回収
        void CollectUPSsCurrentROM(string tempdir, byte[] s)
        {
            //現在のROMデータを保存する.
            {
                string file = Path.GetFileNameWithoutExtension(Program.ROM.Filename);
                string ups  = Path.Combine(tempdir, file + ".ups");
                UPSUtil.MakeUPS(s, Program.ROM.Data, ups);
            }

            //保存していないデータが存在する場合 変更する前のデータをバックアップとして回収する
            if (Program.ROM.Modified && !Program.ROM.IsVirtualROM)
            {
                byte[]   d      = MainFormUtil.OpenROMToByte(Program.ROM.Filename);
                DateTime date   = File.GetLastWriteTime(Program.ROM.Filename);
                string   file   = Path.GetFileNameWithoutExtension(Program.ROM.Filename);
                string   backup = "backup." + date.ToString("yyyyMMddHHmmss");
                string   ups    = Path.Combine(tempdir, file + "." + backup + ".GBA.ups");
                UPSUtil.MakeUPS(s, d, ups);
                U.CopyTimeStamp(Program.ROM.Filename, ups); //タイムスタンプを元のファイルに合わせる.
            }
        }