/// <summary> /// Downloads the game manifest. /// </summary> private void DownloadGameManifest() { try { string RemoteURL = manifestHandler.GetGameManifestURL(); string LocalPath = ManifestHandler.GetGameManifestPath(); string OldLocalPath = ManifestHandler.GetOldGameManifestPath(); if (File.Exists(ManifestHandler.GetGameManifestPath())) { // Create a backup of the old manifest so that we can compare them when updating the game if (File.Exists(OldLocalPath)) { File.Delete(OldLocalPath); } File.Move(LocalPath, OldLocalPath); } DownloadRemoteFile(RemoteURL, LocalPath); } catch (IOException ioex) { Console.WriteLine("IOException in DownloadGameManifest(): " + ioex.Message); } }
/// <summary> /// Downloads the manifest for the specified module, and backs up the old copy of the manifest. /// </summary> /// <exception cref="ArgumentOutOfRangeException"> /// Will be thrown if the <see cref="EModule"/> passed to the function is not a valid value. /// </exception> protected virtual void DownloadModuleManifest(EModule module) { string remoteURL; string localPath; string oldLocalPath; switch (module) { case EModule.Launcher: { remoteURL = ManifestHandler.GetLaunchpadManifestURL(); localPath = ManifestHandler.GetLaunchpadManifestPath(); oldLocalPath = ManifestHandler.GetOldLaunchpadManifestPath(); break; } case EModule.Game: { remoteURL = FileManifestHandler.GetGameManifestURL(); localPath = ManifestHandler.GetGameManifestPath(); oldLocalPath = ManifestHandler.GetOldGameManifestPath(); break; } default: { throw new ArgumentOutOfRangeException(nameof(module), module, "An invalid module value was passed to DownloadModuleManifest"); } } try { // Delete the old backup (if there is one) if (File.Exists(oldLocalPath)) { File.Delete(oldLocalPath); } // Create a backup of the old manifest so that we can compare them when updating the game File.Move(localPath, oldLocalPath); } catch (IOException ioex) { Log.Warn("Failed to back up the old launcher manifest (IOException): " + ioex.Message); } DownloadRemoteFile(remoteURL, localPath); }