public ReleaseManifest.DeployMode GetTargetDeployMode(string project, ReleaseManifest.ReleaseManifestFileEntry originalFileEntry) { LeagueFileDeployMode targetDeployMode = GetTargetLeagueDeployMode(project, originalFileEntry); switch (targetDeployMode) { case LeagueFileDeployMode.Deployed: return(ReleaseManifest.DeployMode.Deployed); case LeagueFileDeployMode.Managed: return(ReleaseManifest.DeployMode.Managed); case LeagueFileDeployMode.RAFCompressed: return(ReleaseManifest.DeployMode.RAFCompressed); case LeagueFileDeployMode.RAFRaw: return(ReleaseManifest.DeployMode.RAFRaw); case LeagueFileDeployMode.SolutionDeployed: return(ReleaseManifest.DeployMode.SolutionDeployed); default: throw new InvalidTargetDeployModeException(); } }
public void InstallFile(string gamePath, string filePath, LeagueDeployRules deployRules) { FileInfo fileToInstall = new FileInfo(filePath); if (!fileToInstall.Exists) { throw new FileToInstallNotFoundException(); } // Getting the matching file entry (null if new file) and finding the deploy mode to use ReleaseManifest.ReleaseManifestFileEntry fileEntry = this.GameManifest.GetFile(gamePath, false); ReleaseManifest.DeployMode deployMode = deployRules.GetTargetDeployMode(this.Project.Name, fileEntry); // Installing file string installPath = this.GetFileToInstallPath(gamePath, deployMode, LeagueInstallation.FantomeFilesVersion); Directory.CreateDirectory(Path.GetDirectoryName(installPath)); if ((fileEntry != null) && deployMode == ReleaseManifest.DeployMode.Deployed) { // Backup deployed file BackupFile(fileEntry, installPath); } File.Copy(filePath, installPath, true); // Setting manifest values if (fileEntry == null) { fileEntry = this.GameManifest.GetFile(gamePath, true); } fileEntry.DeployMode = deployMode; fileEntry.SizeRaw = (int)fileToInstall.Length; fileEntry.SizeCompressed = fileEntry.SizeRaw; fileEntry.Version = LeagueInstallation.FantomeFilesVersion; this.HasChanged = true; }
private LeagueFileDeployMode GetTargetLeagueDeployMode(string project, ReleaseManifest.ReleaseManifestFileEntry originalFileEntry) { LeagueDeployModeRule foundRule = _rules.Find(x => x.Project == project); if (foundRule == null) { foundRule = _rules.Find(x => x.Project == null); } LeagueFileDeployMode originalDeployMode = LeagueFileDeployMode.Default; if (originalFileEntry != null) { switch (originalFileEntry.DeployMode) { case ReleaseManifest.DeployMode.Deployed: originalDeployMode = LeagueFileDeployMode.Deployed; break; case ReleaseManifest.DeployMode.Managed: originalDeployMode = LeagueFileDeployMode.Managed; break; case ReleaseManifest.DeployMode.RAFCompressed: originalDeployMode = LeagueFileDeployMode.RAFCompressed; break; case ReleaseManifest.DeployMode.RAFRaw: originalDeployMode = LeagueFileDeployMode.RAFRaw; break; case ReleaseManifest.DeployMode.SolutionDeployed: originalDeployMode = LeagueFileDeployMode.SolutionDeployed; break; } } return(foundRule.GetTargetDeployMode(originalDeployMode)); }
public void RevertFile(string gamePath) { if (this.OriginalManifest == null) { throw new OriginalManifestNotLoadedException(); } ReleaseManifest.ReleaseManifestFileEntry fileEntry = this.GameManifest.GetFile(gamePath, false); string installedPath = GetFileToInstallPath(gamePath, fileEntry.DeployMode, LeagueInstallation.FantomeFilesVersion); if (File.Exists(installedPath)) { File.Delete(installedPath); } ReleaseManifest.ReleaseManifestFileEntry originalEntry = this.OriginalManifest.GetFile(gamePath, false); if (originalEntry == null) { // Installed file was a new file, remove it. fileEntry.Remove(); } else { // Restore original file if necessary if (originalEntry.DeployMode == ReleaseManifest.DeployMode.Deployed) { RestoreFile(originalEntry, installedPath); } // Revert original values fileEntry.DeployMode = originalEntry.DeployMode; fileEntry.LastWriteTime = originalEntry.LastWriteTime; fileEntry.MD5 = originalEntry.MD5; fileEntry.SizeCompressed = originalEntry.SizeCompressed; fileEntry.SizeRaw = originalEntry.SizeRaw; fileEntry.Version = originalEntry.Version; } this.HasChanged = true; }
private string GetBackupPath(ReleaseManifest.ReleaseManifestFileEntry fileEntry) { return(String.Format("{0}lol-manager/backup/{1}/{2}/{3}", AppDomain.CurrentDomain.BaseDirectory, this.Project.Name, LeagueInstallation.GetReleaseString(fileEntry.Version), fileEntry.GetFullPath())); }
private void RestoreFile(ReleaseManifest.ReleaseManifestFileEntry fileEntry, string filePath) { File.Copy(this.GetBackupPath(fileEntry), filePath, true); }
private void BackupFile(ReleaseManifest.ReleaseManifestFileEntry fileEntry, string filePath) { File.Copy(filePath, this.GetBackupPath(fileEntry), false); }