private void DownloadFile(ProjectRelease projectRelease, ReleaseManifestFileEntry file, string fileOutputPath, string fileFullPath) { // Check if file is already downloaded and is in perfect condition. if (File.Exists(fileOutputPath) && Enumerable.SequenceEqual(file.MD5, CalculateMD5(fileOutputPath))) { return; } Directory.CreateDirectory(Path.GetDirectoryName(fileOutputPath)); RemoteAsset remoteAsset = projectRelease.GetRemoteAsset(file); Console.Write("■ Downloading {0}/{1}", remoteAsset.StringVersion, fileFullPath); try { remoteAsset.AssetContent.WriteAssetToFile(fileOutputPath, false); Console.SetCursorPosition(0, Console.CursorTop); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("■"); } catch (Exception) { Console.SetCursorPosition(0, Console.CursorTop); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("■"); } Console.ResetColor(); }
public DeployMode GetTargetDeployMode(string project, ReleaseManifestFileEntry originalFileEntry) { LeagueRADSFileDeployMode targetDeployMode = GetTargetLeagueDeployMode(project, originalFileEntry); switch (targetDeployMode) { case LeagueRADSFileDeployMode.Deployed0: return(DeployMode.Deployed0); case LeagueRADSFileDeployMode.Managed: return(DeployMode.Managed); case LeagueRADSFileDeployMode.RAFCompressed: return(DeployMode.RAFCompressed); case LeagueRADSFileDeployMode.RAFRaw: return(DeployMode.RAFRaw); case LeagueRADSFileDeployMode.Deployed4: return(DeployMode.Deployed4); default: throw new InvalidTargetDeployModeException(); } }
private void RestoreFile(ReleaseManifestFileEntry fileEntry, string filePath) { string backupPath = this.GetBackupPath(fileEntry); using (Stream backupStream = Project.BackupArchive.GetBackupFileStream(backupPath)) { using (FileStream fs = new FileStream(filePath, FileMode.Create)) { backupStream.CopyTo(fs); } } }
private void BackupFile(ReleaseManifestFileEntry fileEntry, string filePath) { string backupPath = this.GetBackupPath(fileEntry); if (!Project.BackupArchive.HasFile(backupPath)) { using (FileStream fs = new FileStream(filePath, FileMode.Open)) { Project.BackupArchive.AddFile(backupPath, fs); } } }
public RemoteAsset(ReleaseManifestFileEntry fileEntry, string projectURL) { this.FileEntry = fileEntry; this.StringVersion = Utilities.GetReleaseString(fileEntry.Version); this.FileFullPath = fileEntry.GetFullPath(); this.IsCompressed = this.FileEntry.SizeCompressed > 0; this.RemoteURL = Uri.EscapeUriString(String.Format("{0}/releases/{1}/files/{2}", projectURL, this.StringVersion, this.FileFullPath)); if (this.IsCompressed) { this.RemoteURL += ".compressed"; } this.AssetContent = new AssetContent(this.IsCompressed, this.RemoteURL); }
public void RevertFile(string gamePath, byte[] md5) { ReleaseManifestFileEntry fileEntry = this.GameManifest.GetFile(gamePath, false); if (fileEntry == null) { throw new NotFoundFileEntryException(); } if (md5 != null && !fileEntry.MD5.SequenceEqual(md5)) { return; } string installedPath = Project.GetFileInstallationPath(gamePath, fileEntry.DeployMode, fileEntry.Version); ReleaseManifestFileEntry originalEntry = this.OriginalManifest.GetFile(gamePath, false); if (originalEntry == null) { // Installed file was a new file, remove it. if (File.Exists(installedPath)) { File.Delete(installedPath); } fileEntry.Remove(); } else { // Restore original file if necessary if (HasToRestore(originalEntry.DeployMode, fileEntry.DeployMode)) { if (!originalEntry.MD5.SequenceEqual(fileEntry.MD5)) { RestoreFile(originalEntry, installedPath); } } else if (File.Exists(installedPath)) { File.Delete(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; } HasChanged = true; }
public RemoteAsset(ReleaseManifestFileEntry fileEntry, string projectURL) { this.FileEntry = fileEntry; this.StringVersion = Utilities.GetReleaseString(fileEntry.Version); this.FileFullPath = fileEntry.GetFullPath(); this.IsCompressed = this.FileEntry.SizeCompressed > 0; string[] fileParts = this.FileFullPath.Split('/'); for (int i = 0; i < fileParts.Length; i++) { fileParts[i] = Uri.EscapeDataString(fileParts[i]); } this.RemoteURL = string.Format("{0}/releases/{1}/files/{2}", projectURL, this.StringVersion, string.Join("/", fileParts)); if (this.IsCompressed) { this.RemoteURL += ".compressed"; } this.AssetContent = new AssetContent(this.IsCompressed, this.RemoteURL); }
public void InstallFile(string gamePath, string filePath, LeagueRADSDeployRules deployRules) { FileInfo fileToInstall = new FileInfo(filePath); // Getting the matching file entry (null if new file) ReleaseManifestFileEntry fileEntry = this.GameManifest.GetFile(gamePath, false); // File is already installed, don't install it again byte[] fileMD5 = LeagueInstallation.CalculateMD5(filePath); if (fileEntry != null && fileEntry.MD5.SequenceEqual(fileMD5)) { return; } // Finding the deploy mode to use ReleaseManifestFile.DeployMode deployMode = deployRules.GetTargetDeployMode(this.Project.Name, fileEntry); // Installing file string installPath = Project.GetFileInstallationPath(gamePath, deployMode, LeagueRADSInstallation.FantomeFilesVersion); Directory.CreateDirectory(Path.GetDirectoryName(installPath)); if (fileEntry != null && (deployMode == ReleaseManifestFile.DeployMode.Deployed4 || deployMode == ReleaseManifestFile.DeployMode.Deployed0)) { // Backup deployed file BackupFile(fileEntry, installPath); } File.Copy(filePath, installPath, true); // Setting manifest values if (fileEntry == null) { fileEntry = this.GameManifest.GetFile(gamePath, true); } fileEntry.MD5 = fileMD5; fileEntry.DeployMode = deployMode; fileEntry.SizeRaw = (int)fileToInstall.Length; fileEntry.SizeCompressed = fileEntry.SizeRaw; fileEntry.Version = LeagueRADSInstallation.FantomeFilesVersion; this.HasChanged = true; }
public ReleaseManifestFileEntry GetFile(string path, bool createIfNotFound) { string[] folders = path.Split('/'); string folderPath = path.Substring(0, path.Length - folders[folders.Length - 1].Length); ReleaseManifestFolderEntry gotFolder = this.GetFolder(folderPath, createIfNotFound); if (gotFolder == null) { return(null); } else { ReleaseManifestFileEntry foundFile = gotFolder.Files.Find(x => String.Equals(x.Name, folders[folders.Length - 1], StringComparison.InvariantCultureIgnoreCase)); if (foundFile == null && createIfNotFound) { foundFile = new ReleaseManifestFileEntry(folders[folders.Length - 1], this.GetNameIndex(folders[folders.Length - 1]), gotFolder); gotFolder.Files.Add(foundFile); } return(foundFile); } }
private LeagueRADSFileDeployMode GetTargetLeagueDeployMode(string project, ReleaseManifestFileEntry originalFileEntry) { LeagueRADSDeployModeRule foundRule = _rules.Find(x => x.Project == project); if (foundRule == null) { foundRule = _rules.Find(x => x.Project == null); } LeagueRADSFileDeployMode originalDeployMode = LeagueRADSFileDeployMode.Default; if (originalFileEntry != null) { switch (originalFileEntry.DeployMode) { case DeployMode.Deployed0: originalDeployMode = LeagueRADSFileDeployMode.Deployed0; break; case DeployMode.Managed: originalDeployMode = LeagueRADSFileDeployMode.Managed; break; case DeployMode.RAFCompressed: originalDeployMode = LeagueRADSFileDeployMode.RAFCompressed; break; case DeployMode.RAFRaw: originalDeployMode = LeagueRADSFileDeployMode.RAFRaw; break; case DeployMode.Deployed4: originalDeployMode = LeagueRADSFileDeployMode.Deployed4; break; } } return(foundRule.GetTargetDeployMode(originalDeployMode)); }
private void ExportFile(ContentConfiguration configuration, ReleaseManifestFileEntry file) { // Load and convert var inibin = _manager.ReadInibin(file.FullName); var item = ContentFile.FromInibin(inibin, configuration); // Find save path var savePath = string.Format( "{0}/{1}", OutputDirectory, configuration.GetTargetName(file.FullName) ); // Create save directory if one doesn't exist var saveDirectory = Path.GetDirectoryName(savePath); if (!Directory.Exists(saveDirectory)) { Directory.CreateDirectory(saveDirectory); } // Save the converted data File.WriteAllText(savePath, item.Serialize()); }
public RemoteAsset GetRemoteAsset(ReleaseManifestFileEntry fileEntry) { return(new RemoteAsset(fileEntry, this.ProjectBaseURL)); }
public string GetFileInstallationPath(ReleaseManifestFileEntry fileEntry) { return(GetFileInstallationPath(fileEntry.GetFullPath(), fileEntry.DeployMode, fileEntry.Version)); }
private string GetBackupPath(ReleaseManifestFileEntry fileEntry) { return(Path.Combine(LeagueRADSInstallation.GetReleaseString(fileEntry.Version), fileEntry.GetFullPath())); }