Beispiel #1
0
        static void Rotate(string current)
        {
            {
                string oldlog2 = GeOldLogFilename(GEN_COUNT);
                if (File.Exists(oldlog2))
                {
                    File.Delete(oldlog2);
                }
            }
            for (int i = GEN_COUNT; i > 0; i--)
            {
                string oldlog1 = GeOldLogFilename(i - 1);
                string oldlog2 = GeOldLogFilename(i);

                if (File.Exists(oldlog1))
                {
                    File.Move(oldlog1, oldlog2);
                }
            }
            {
                string oldlog2 = GeOldLogFilename(0);
                ArchSevenZip.Compress(oldlog2, current);
                File.Delete(current);
            }
        }
Beispiel #2
0
        string MakeReport(string fullfilename)
        {
            //少し時間がかかるので、しばらくお待ちください表示.
            using (InputFormRef.AutoPleaseWait pleaseWait = new InputFormRef.AutoPleaseWait(this))
                //テンポラリディレクトリを利用する
                using (U.MakeTempDirectory tempdir = new U.MakeTempDirectory())
                {
                    string orignalFilename = OrignalFilename.Text;
                    byte[] s = File.ReadAllBytes(orignalFilename);

                    //セーブデータの回収
                    CollectSaveData(tempdir.Dir);

                    //現在のROMのUPSデータの回収
                    CollectUPSsCurrentROM(tempdir.Dir, s);

                    //動作しないUPSと動作するUPSデータの回収
                    CollectOldUPSs(tempdir.Dir, s);

                    //ログとユーザの説明を書き込む
                    string log = Path.Combine(tempdir.Dir, "log.txt");
                    U.WriteAllText(log, MakeReportLog());

                    //etcの内容をコピー
                    //lintやコメントなどの設定がほしい
                    CopyEtcData(tempdir.Dir);

                    //添付データ
                    AttachData(tempdir.Dir);

                    //7z圧縮
                    InputFormRef.DoEvents(this, R._("7z圧縮中"));
                    return(ArchSevenZip.Compress(fullfilename, tempdir.Dir));
                }
        }
Beispiel #3
0
        string DownloadProgram_Direct(string url, string dir, string findEXE)
        {
            string tempFilename = Path.GetTempFileName();

            try
            {
                U.HttpDownload(tempFilename, url, U.GetURLBaseDir(url), this.SettingPleaseWait);
            }
            catch (Exception e)
            {
                File.Delete(tempFilename);
                return(R.Error("ファイルをダウンロードできませんでした。\r\nURL:{0}\r\nPATH:{1}\r\nfindEXE:{2}", url, dir, findEXE) + "\r\n" + e.ToString());
            }

            if (!File.Exists(tempFilename))
            {
                return(R.Error("ファイルをダウンロードできませんでした。\r\nURL:{0}\r\nPATH:{1}\r\nfindEXE:{2}", url, dir, findEXE));
            }

            try
            {
                string ext = Path.GetExtension(U.GetURLFilename(url));
                if (ext == "")
                {
                    ext = ".zip";
                }
                else if (ext == ".exe" || ext == ".EXE")
                {
                    string filename = U.GetURLFilename(url);
                    string retPath  = Path.Combine(dir, filename);

                    U.mkdir(dir);
                    File.Copy(tempFilename, retPath, true);
                    File.Delete(tempFilename);
                    return(retPath);
                }

                File.Move(tempFilename, tempFilename + ext);
                tempFilename = tempFilename + ext;

                this.SettingPleaseWait.DoEvents("Extract...");
                U.mkdir(dir);
                string r = ArchSevenZip.Extract(tempFilename, dir);
                if (r != "")
                {
                    return(R.Error("ダウンロードしたファイルを解凍できませんでした。\r\nURL:{0}\r\nPATH:{1}\r\nfindEXE:{2}", url, dir, findEXE));
                }

                File.Delete(tempFilename);
                return(GrepFile(dir, findEXE));
            }
            catch (Exception e)
            {
                return(R.Error("ダウンロードしたファイルを開けませんでした。\r\nURL:{0}\r\nPATH:{1}\r\nfindEXE:{2}", url, dir, findEXE) + "\r\n" + e.ToString());
            }
        }
        string MakeFeedBack(string fullfilename)
        {
            //テンポラリディレクトリを利用する
            using (U.MakeTempDirectory tempdir = new U.MakeTempDirectory())
            {
                //セーブデータの回収
                ToolProblemReportForm.CollectSaveData(tempdir.Dir);

                //フィードバックコメント
                File.WriteAllText(Path.Combine(tempdir.Dir, "log.txt"), MakeFeedBackInfo());

                //7z圧縮
                InputFormRef.DoEvents(this, R._("7z圧縮中"));
                return(ArchSevenZip.Compress(fullfilename, tempdir.Dir));
            }
        }
        bool DownloadAndExtract(string download_url, InputFormRef.AutoPleaseWait pleaseWait)
        {
            string romdir   = Path.GetDirectoryName(Program.ROM.Filename);
            string update7z = Path.GetTempFileName();

            //ダウンロード
            try
            {
                U.DownloadFile(update7z, download_url, pleaseWait);
            }
            catch (Exception ee)
            {
                BrokenDownload(R.ExceptionToString(ee));
                return(false);
            }
            if (!File.Exists(update7z))
            {
                BrokenDownload(R._("ダウンロードしたはずのファイルがありません。"));
                return(false);
            }
            if (U.GetFileSize(update7z) <= 256)
            {
                BrokenDownload(R._("ダウンロードしたファイルが小さすぎます。"));
                File.Delete(update7z);
                return(false);
            }

            pleaseWait.DoEvents("Extract...");

            if (UPSUtil.IsUPSFile(update7z))
            {
                string upsName = Path.Combine(romdir, RecomendUPSName(download_url));
                File.Copy(update7z, upsName, true);
            }
            else
            {
                //解凍
                try
                {
                    using (U.MakeTempDirectory t = new U.MakeTempDirectory())
                    {
                        string r = ArchSevenZip.Extract(update7z, t.Dir);
                        if (r != "")
                        {
                            BrokenDownload(R._("ダウンロードしたファイルを解凍できませんでした。") + "\r\n" + r);
                            return(false);
                        }
                        U.CopyDirectory1Trim(t.Dir, romdir);
                    }
                }
                catch (Exception ee)
                {
                    BrokenDownload(R.ExceptionToString(ee));
                    File.Delete(update7z);
                    return(false);
                }
            }
            File.Delete(update7z);
            pleaseWait.DoEvents("Select Vanilla ROM");

            string[] ups_files = U.Directory_GetFiles_Safe(romdir, "*.ups", SearchOption.AllDirectories);
            if (ups_files.Length <= 0)
            {
                BrokenDownload(R._("UPSファイルが見つかりませんでした"));
                return(false);
            }

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

            f.OpenUPS(ups_files[0]);
            if (f.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return(false);
            }

            pleaseWait.DoEvents("UPS");
            string orignalROMFilename = f.GetOrignalFilename();

            if (orignalROMFilename == "")
            {
                return(false);
            }

            for (int i = 0; i < ups_files.Length; i++)
            {
                ROM    rom = new ROM();
                string version;
                bool   rr = rom.Load(orignalROMFilename, out version);
                if (!rr)
                {
                    R.ShowStopError("未対応のROMです。\r\ngame version={0}", version);
                    return(false);
                }

                rr = UPSUtil.ApplyUPS(rom, ups_files[i]);
                if (!rr)
                {
                    R.ShowStopError("UPSパッチを適応できませんでした" + "\r\n" + ups_files[i]);
                }

                string savegba = U.ChangeExtFilename(ups_files[i], ".gba");
                rom.Save(savegba, true);
            }

            pleaseWait.DoEvents("ReOpen...");
            MainFormUtil.ForceReopen();
            return(true);
        }
Beispiel #6
0
        private void AutoUpdateButton_Click(object sender, EventArgs e)
        {
            if (InputFormRef.IsPleaseWaitDialog(this))
            {//2重割り込み禁止
                return;
            }

            if (Program.ROM != null && Program.ROM.Modified)
            {
                DialogResult dr = R.ShowQ("未保存の変更があるようです。\r\n保存してもよろしいですか?");
                if (dr == System.Windows.Forms.DialogResult.Yes)
                {
                    MainFormUtil.SaveForce(Program.MainForm());
                }
                else if (dr == System.Windows.Forms.DialogResult.Cancel)
                {
                    return;
                }
            }

            //少し時間がかかるので、しばらくお待ちください表示.
            using (InputFormRef.AutoPleaseWait pleaseWait = new InputFormRef.AutoPleaseWait(this))
            {
                //実行中のファイルは上書きできないので、アップデーターに処理を引き継がなくてはいけない。

                string updater_org_txt = System.IO.Path.Combine(Program.BaseDirectory, "config", "data", "updater.bat.txt");
                string updater         = Path.Combine(Program.BaseDirectory, "updater.bat");
                if (!File.Exists(updater_org_txt))
                {
                    BrokenDownload(R._("アップデーターのバッチファイルがありません。\r\n{0}", updater_org_txt));
                    this.Close();
                    return;
                }

                try
                {
                    File.Copy(updater_org_txt, updater, true);
                }
                catch (Exception ee)
                {
                    BrokenDownload(R._("アップデーターのバッチファイルをコピーできませんでした。\r\n{0}", ee.ToString()));
                    this.Close();
                    return;
                }

                if (!File.Exists(updater))
                {
                    BrokenDownload(R._("アップデーターのバッチファイルをコピーできませんでした。\r\n{0}", updater));
                    this.Close();
                    return;
                }


                string update7z = Path.Combine(Program.BaseDirectory, "dltemp_" + DateTime.Now.Ticks.ToString() + ".7z");

                //ダウンロード
                try
                {
                    DownloadNewVersion(update7z, this.URL, this.Version, pleaseWait);
                }
                catch (Exception ee)
                {
                    BrokenDownload(ee);
                    this.Close();
                    return;
                }
                if (!File.Exists(update7z))
                {
                    BrokenDownload(R._("ダウンロードしたはずのファイルがありません。"));
                    this.Close();
                    return;
                }
                if (U.GetFileSize(update7z) < 2 * 1024 * 1024)
                {
                    BrokenDownload(R._("ダウンロードしたファイルが小さすぎます。"));
                    this.Close();
                    return;
                }

                pleaseWait.DoEvents("Extract...");

                //解凍
                try
                {
                    string _update = Path.Combine(Program.BaseDirectory, "_update");
                    U.mkdir(_update);
                    string r = ArchSevenZip.Extract(update7z, _update);
                    if (r != "")
                    {
                        BrokenDownload(R._("ダウンロードしたファイルを解凍できませんでした。") + "\r\n" + r);
                        this.Close();
                        return;
                    }
                }
                catch (Exception ee)
                {
                    BrokenDownload(ee);
                    this.Close();
                    return;
                }

                string updateNewVersionFilename = Path.Combine(Program.BaseDirectory, "_update", "FEBuilderGBA.exe");
                if (!File.Exists(updateNewVersionFilename))
                {
                    BrokenDownload(R._("ダウンロードしたファイルを解凍した中に、実行ファイルがありませんでした。"));
                    this.Close();
                    return;
                }
                if (U.GetFileSize(updateNewVersionFilename) < 2 * 1024 * 1024)
                {
                    BrokenDownload(R._("ダウンロードしたファイルを解凍した中にあった、実行ファイルが小さすぎます。"));
                    this.Close();
                    return;
                }

                pleaseWait.DoEvents("GO!");

                int    pid  = Process.GetCurrentProcess().Id;
                string args = pid.ToString();
                try
                {
                    Process p = new Process();
                    p.StartInfo.FileName        = updater;
                    p.StartInfo.Arguments       = args;
                    p.StartInfo.UseShellExecute = false;
                    p.Start();
                }
                catch (Exception ee)
                {
                    BrokenDownload(ee);
                    return;
                }
            }

            Application.Exit();

            this.Close();
            this.DialogResult = System.Windows.Forms.DialogResult.Abort;
        }