public void Run() { if (_watcher != null) { return; } _resultFilename = AcPaths.GetResultJsonFilename(); FileUtils.EnsureFileDirectoryExists(_resultFilename); _timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(0.5), IsEnabled = true }; _timer.Tick += OnTick; _watcher = new FileSystemWatcher(Path.GetDirectoryName(_resultFilename) ?? "") { NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName, IncludeSubdirectories = false, EnableRaisingEvents = true, }; _watcher.Changed += FileUpdate; _watcher.Created += FileUpdate; PreviewRun?.Invoke(this, new AcsRunEventArgs(null, null)); }
public void Run() { SteamRunningHelper.EnsureSteamIsRunning(RunSteamIfNeeded, false); _acLauncher = AcPaths.GetAcLauncherFilename(AcRoot); _acLauncherBackup = _acLauncher.ApartFromLast(".exe", StringComparison.OrdinalIgnoreCase) + "_backup_ts.exe"; if (File.Exists(_acLauncherBackup) && new FileInfo(_acLauncher).Length > ApproximateAcstarterSize) { File.Move(_acLauncherBackup, _acLauncherBackup.ApartFromLast(".exe", StringComparison.OrdinalIgnoreCase) + "_" + DateTime.Now.Ticks + ".exe"); } if (!File.Exists(_acLauncherBackup)) { File.Move(_acLauncher, _acLauncherBackup); } if (!File.Exists(_acLauncher)) { File.WriteAllBytes(_acLauncher, Resources.AcStarter); } PreviewRun?.Invoke(this, new AcsRunEventArgs(Path.Combine(AcRoot, AcsName), Use32BitVersion)); _launcherProcess = Process.Start(new ProcessStartInfo { WorkingDirectory = AcRoot, FileName = Path.GetFileName(_acLauncher), Arguments = $"--first-stage {AcsName}" }); }
protected void RaisePreviewRunEvent([CanBeNull] string acsFilename) { PreviewRun?.Invoke(this, new AcsRunEventArgs(acsFilename, Use32BitVersion)); }