/// <summary> /// Downloads the manifest. /// </summary> public void DownloadManifest() { Stream manifestStream = null; try { FTPHandler FTP = new FTPHandler(); string remoteChecksum = FTP.GetRemoteManifestChecksum(); string localChecksum = ""; string RemoteURL = Config.GetManifestURL(); string LocalPath = ConfigHandler.GetManifestPath(); if (File.Exists(ConfigHandler.GetManifestPath())) { manifestStream = File.OpenRead(ConfigHandler.GetManifestPath()); localChecksum = MD5Handler.GetFileHash(manifestStream); if (!(remoteChecksum == localChecksum)) { //Copy the old manifest so that we can compare them when updating the game File.Copy(LocalPath, LocalPath + ".old", true); FTP.DownloadFTPFile(RemoteURL, LocalPath, false); } } else { FTP.DownloadFTPFile(RemoteURL, LocalPath, false); } } catch (IOException ioex) { Console.WriteLine("IOException in DownloadManifest(): " + ioex.Message); } finally { if (manifestStream != null) { manifestStream.Close(); } } }
/// <summary> /// Determines whether the manifest is outdated. /// </summary> /// <returns><c>true</c> if the manifest is outdated; otherwise, <c>false</c>.</returns> public bool IsManifestOutdated() { if (File.Exists(ConfigHandler.GetManifestPath())) { FTPHandler FTP = new FTPHandler(); string manifestURL = Config.GetManifestURL(); string remoteHash = FTP.ReadFTPFile(manifestURL); string localHash = MD5Handler.GetFileHash(File.OpenRead(ConfigHandler.GetManifestPath())); if (remoteHash != localHash) { return(true); } else { return(false); } } else { return(true); } }