private void StopProgressBar() { if (_progressBar?.Stop() ?? false) { HasWroteToOuput = false; } }
private void DownloadNextFile() { Console.Clear(); Progress.Stop(); if (CurrentFileIndex >= Files.Count) { CurrentFile = null; return; } CurrentFile = Files[CurrentFileIndex]; if (!Directory.Exists(BasePath + CurrentFile.Directory)) { Directory.CreateDirectory(BasePath + CurrentFile.Directory); } if (File.Exists(BasePath + CurrentFile.Path)) { File.Delete(BasePath + CurrentFile.Path); } Client.DownloadFileAsync(new Uri(CurrentFile.Url), BasePath + CurrentFile.Path); Progress.Start(); }
/// <summary> /// Moves the files from the chunked archive to a flat file one /// </summary> /// <param name="archivename"></param> /// <param name="block"></param> private void DoFileSwap(string archivename, string block) { Directory.CreateDirectory("Temp"); string filename = Path.GetFileName(archivename); using (var mpq = MpqArchive.CreateNew(archivename, MpqArchiveVersion.Version3)) using (var tmp = new MpqArchive(block, FileAccess.Read, OpenArchiveFlags.BLOCK4)) { if (TryGetFileList(tmp, false, out var lf)) { _progressBar.Start(); string tempPath; for (int i = 0; i < lf.Count; i++) { using (var fs = tmp.OpenFile(lf[i])) { // incremental patch files can't be written directly with StormLib SFileCreateFile? if ((fs.TFileEntry.dwFlags & 0x100000u) != 0x100000u) { mpq.AddFileFromStream(fs); } else { tempPath = Path.Combine("Temp", lf[i]); Directory.CreateDirectory(Path.GetDirectoryName(tempPath)); tmp.ExtractFile(lf[i], tempPath); mpq.AddFileFromDisk(tempPath, lf[i], fs.TFileEntry.dwFlags); } } _progressBar.Update(filename, i / (float)lf.Count); if (i % 10000 == 0) { mpq.Flush(); } } } } Console.WriteLine("Emptying Temp Folder..."); DeleteDirectory("Temp"); _progressBar.Stop(); }