Nexus.Client.ModManagement.CategoryManager.Restore C# (CSharp) Method

Restore() public static method

This restores the first valid backup of the category file.
public static Restore ( string p_strCategoryPath ) : bool
p_strCategoryPath string The path to the category folder.
return bool
		public static bool Restore(string p_strCategoryPath)
		{
			string strSuffix = "." + DateTime.Now.ToString("yyyyMMddHHmmss") + ".bad";
			if (File.Exists(p_strCategoryPath))
				FileUtil.Move(p_strCategoryPath, p_strCategoryPath + strSuffix, true);
			string strBackupCategoryPath = p_strCategoryPath + ".bak";
			if (IsValid(strBackupCategoryPath))
			{
				File.Copy(strBackupCategoryPath, p_strCategoryPath, true);
				return true;
			}
			if (File.Exists(strBackupCategoryPath))
				FileUtil.Move(strBackupCategoryPath, strBackupCategoryPath + strSuffix, true);
			for (Int32 i = 1; i < 6; i++)
			{
				if (IsValid(strBackupCategoryPath + i))
				{
					FileUtil.Move(strBackupCategoryPath + i, p_strCategoryPath, true);
					return true;
				}
				if (File.Exists(strBackupCategoryPath + i))
					FileUtil.Move(strBackupCategoryPath + i, strBackupCategoryPath + i + strSuffix, true);
			}
			return false;
		}