public static ManifestFile FromRepository(WoWRepository repository) { try { var manifest = new ManifestFile(); var client = new WebClient(); string content = client.DownloadString(repository.GetBaseUrl() + repository.GetMFilName()); string[] lines = content.Split('\n'); foreach (string line in lines) { if (line.Trim().StartsWith("version=")) { int output; if (int.TryParse(line.Trim().Replace("version=", ""), out output)) { manifest.Version = output; } } manifest.Lines.Add(line.Trim().Replace("file=", repository.GetBaseUrl())); } return(manifest); } catch (Exception ex) { Program.Log("Unable to retrieve Manifest file", ConsoleColor.Red); Program.Log(ex.Message, ConsoleColor.Red); } return(null); }
public List <FileObject> GenerateFileList() { WoWRepository repository = RepositoriesManager.GetRepositoryByMfil(WoWRegeneration.CurrentSession.MFil); var tmp = new List <FileObject>(); foreach (string line in Lines) { if (IsLineARepositorFile(repository, line)) { var file = new FileObject { Path = GetFilePath(line) }; if (file.Path == null) { continue; } file.Url = line; file.Info = GetFileInfo(repository, line); if (IsAcceptedFile(repository, file)) { tmp.Add(file); } } } return(tmp); }
public FileDownloader(WoWRepository repository, List <FileObject> files) { Files = files; BasePath = repository.GetDefaultDirectory(); Progress = new ConsoleDownloadProgressBar(Files.Count); }
public FileDownloader(WoWRepository repository, List <FileObject> files) { Files = files; BasePath = repository.GetDefaultDirectory(); Progress = new ConsoleDownloadProgressBar(Files.Count); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new UI.ProgressBar()); }
private bool IsLineARepositorFile(WoWRepository repository, string line) { if (line.StartsWith(repository.GetBaseUrl())) { if (line.Substring(line.Length - 4, 1) == ".") { return(true); } } return(false); }
private static void EntryPointResumeSession(Session previousSession) { CurrentSession = previousSession; WoWRepository repository = RepositoriesManager.GetRepositoryByMfil(CurrentSession.MFil); ManifestFile manifest = ManifestFile.FromRepository(repository); CurrentSession.SaveSession(); StartProcess(manifest); }
private static void EntryPointNewSession() { WoWRepository repository = UserInputs.SelectRepository(); ManifestFile manifest = ManifestFile.FromRepository(repository); string locale = UserInputs.SelectLocale(manifest); string os = UserInputs.SelectOs(); CurrentSession = new Session(repository.GetMFilName(), locale, os); CurrentSession.SaveSession(); StartProcess(manifest); }
public Session(string mfil, string locale, string os) : this() { MFil = mfil; Locale = locale; Os = os; WoWRepository rep = RepositoriesManager.GetRepositoryByMfil(mfil); if (rep == null) { throw new Exception("Unknow mfil file"); } WoWRepositoryName = rep.GetVersionName(); }
private static void StartProcess(ManifestFile manifest) { Program.Log("Generating file list"); WoWRepository repository = RepositoriesManager.GetRepositoryByMfil(CurrentSession.MFil); List <FileObject> files = manifest.GenerateFileList(); var downloader = new FileDownloader(repository, files); downloader.Start(); CurrentSession.SessionCompleted = true; CurrentSession.SaveSession(); CurrentSession.Destroy(); Program.Log("Download Complete !!", ConsoleColor.Green); }
private bool IsAcceptedFile(WoWRepository repository, FileObject file) { if (WoWRegeneration.CurrentSession.Os == "Win" && file.Filename == "base-OSX.MPQ") { return(false); } if (WoWRegeneration.CurrentSession.Os == "OSX" && file.Filename == "base-Win.MPQ") { return(false); } if (file.Filename == "alternate.MPQ" && WoWRegeneration.CurrentSession.Locale != "All" && file.Info != WoWRegeneration.CurrentSession.Locale) { return(false); } if (WoWRegeneration.CurrentSession.CompletedFiles.Contains(file.Path) && File.Exists(Program.ExecutionPath + repository.GetDefaultDirectory() + file.Path)) { Program.Log("Skipping " + file.Filename + " allready downloaded", ConsoleColor.DarkGray); return(false); } if (WoWRegeneration.CurrentSession.CompletedFiles.Contains(file.Path)) { WoWRegeneration.CurrentSession.CompletedFiles.Remove(file.Path); WoWRegeneration.CurrentSession.SaveSession(); } if (file.Directory == "Data/") { return(true); } if (file.Directory.StartsWith("Data/Interface/")) { return(true); } if (WoWRegeneration.CurrentSession.Locale == "All" || file.Directory.StartsWith("Data/" + WoWRegeneration.CurrentSession.Locale)) { return(true); } return(false); }
private string GetFileInfo(WoWRepository repository, string line) { int index = Lines.IndexOf(line); for (int n = 1; n <= 5; n++) { string next = Lines[index + n]; if (IsLineARepositorFile(repository, next)) { return(null); } if (next.StartsWith("path=locale_")) { return(next.Replace("path=locale_", "")); } } return(null); }
private long GetFileSize(WoWRepository repository, string line) { int index = Lines.IndexOf(line); for (int n = 1; n <= 5; n++) { string next = Lines[index + n]; if (IsLineARepositorFile(repository, next)) { return(0); } if (next.StartsWith("path=locale_")) { return(0); } if (next.StartsWith("size=")) { return(long.Parse(next.Replace("size=", ""))); } } return(0); }