/// <summary> /// Determines whether the game is installed. /// </summary> /// <returns><c>true</c> if the game is installed; otherwise, <c>false</c>.</returns> public bool IsGameInstalled() { //Criteria for considering the game 'installed' //Does the game directory exist? bool bHasDirectory = Directory.Exists(Config.GetGamePath()); //Is there an .install file in the directory? bool bHasInstallationCookie = File.Exists(ConfigHandler.GetInstallCookiePath()); //is there a version file? bool bHasGameVersion = File.Exists(Config.GetGameVersionPath()); //If any of these criteria are false, the game is not considered fully installed. return(bHasDirectory && bHasInstallationCookie && IsInstallCookieEmpty() && bHasGameVersion); }
/// <summary> /// Determines whether the install cookie is empty /// </summary> /// <returns><c>true</c> if the install cookie is empty, otherwise, <c>false</c>.</returns> public static bool IsInstallCookieEmpty() { //Is there an .install file in the directory? bool bHasInstallationCookie = File.Exists(ConfigHandler.GetInstallCookiePath()); //Is the .install file empty? Assume false. bool bIsInstallCookieEmpty = false; if (bHasInstallationCookie) { bIsInstallCookieEmpty = String.IsNullOrEmpty(File.ReadAllText(ConfigHandler.GetInstallCookiePath())); } return(bIsInstallCookieEmpty); }
/// <summary> /// Determines whether the game is installed. /// </summary> /// <returns><c>true</c> if the game is installed; otherwise, <c>false</c>.</returns> public bool IsGameInstalled() { // Criteria for considering the game 'installed' // Does the game directory exist? bool bHasGameDirectory = Directory.Exists(Configuration.GetGamePath()); // Is there an .install file in the directory? bool bHasInstallationCookie = File.Exists(ConfigHandler.GetInstallCookiePath()); // Is there a version file? bool bHasGameVersion = File.Exists(Configuration.GetGameVersionPath()); if (!bHasGameVersion && bHasGameDirectory) { Log.Warn("No GameVersion.txt file was found in the installation directory.\n" + "This may be due to a download error, or the develop may not have included one.\n" + "Without it, the game cannot be considered fully installed.\n" + "If you are the developer of this game, add one to your game files with your desired version in it."); } // If any of these criteria are false, the game is not considered fully installed. return(bHasGameDirectory && bHasInstallationCookie && IsInstallCookieEmpty() && bHasGameVersion); }