public void Initialise(string patchPath) { log.Info("Loading archives..."); // CoreData archive only applicable to Steam client ArchiveFile coreDataArchive = null; if (File.Exists(Path.Combine(patchPath, "CoreData.archive"))) { coreDataArchive = ArchiveFileBase.FromFile(Path.Combine(patchPath, "CoreData.archive")) as ArchiveFile; } MainArchive = Archive.FromFile(Path.Combine(patchPath, "ClientData.index"), coreDataArchive); foreach (string localisationArchivePath in localisationIndexes .Select(i => Path.Combine(patchPath, i))) { if (!File.Exists(localisationArchivePath)) { continue; } LocalisationArchives.Add(Archive.FromFile(localisationArchivePath, coreDataArchive)); } }
private async Task PatchIndex(string file, string targetPath) { var patcher = new Patcher.Patcher(PatchSource, (IndexFile)ArchiveFileBase.FromFile(file), CoreData, targetPath); patcher.Progress += OnProgressUpdated; await patcher.Patch(CancellationToken.None); }
static void Main(string[] args) { if (args.Length < 1 || args.Length > 2) { Console.WriteLine("TableExtractor.exe PatchFolderPath <output directory>"); return; } var outputPath = "tbl"; if (args.Length == 2) { outputPath = args[1]; } var coreDataArchivePath = Path.Combine(args[0], "CoreData.archive"); ArchiveFile coreDataArchive = null; if (File.Exists(coreDataArchivePath)) { coreDataArchive = ArchiveFileBase.FromFile(Path.Combine(args[0], "CoreData.archive")) as ArchiveFile; } outputPath = Directory.CreateDirectory(outputPath).FullName; Console.WriteLine("Extracting files from index files in {0} to target path {1}", args[0], outputPath); foreach (var index in IndexFiles.Select(i => Path.Combine(args[0], i))) { if (!File.Exists(index)) { Console.WriteLine("Skipping missing file {0}", index); continue; } try { var archive = Archive.FromFile(index, coreDataArchive); ProcessArchive(archive, outputPath); } catch (Exception ex) { Console.WriteLine("Error processing {0}", index); Console.WriteLine(ex); } } }
static void Main(string[] args) { var patchPath = Path.GetFullPath(args[0]); var coreDataArchivePath = Path.Combine(patchPath, "CoreData.archive"); ArchiveFile coreDataArchive = File.Exists(coreDataArchivePath) ? (ArchiveFile)ArchiveFileBase.FromFile(coreDataArchivePath) : null; var unpackBasePath = Path.GetFullPath(args.Length > 1 ? args[1] : Path.Combine(patchPath, "..", "Data")); var archives = Directory.EnumerateFiles(patchPath, "*.index").Select(i => Archive.FromFile(i, coreDataArchive)) .Where(i => i.HasArchiveFile).ToArray(); foreach (var archive in archives) { ExtractArchive(archive, unpackBasePath, true); } }
protected GameDataFiles(string basePath, int build, IEnumerable <AdditionalFile> configuredFiles, ILogger <GameDataFiles> logger) { Logger = logger; var additionalFiles = configuredFiles?.ToList() ?? new List <AdditionalFile>(); var dataFiles = new List <ArchiveFileBase>(); _fileEntries = new List <FileEntry>(); foreach (var indexFile in Directory.EnumerateFiles(basePath, "*.index", SearchOption.AllDirectories)) { var stopwatch = Stopwatch.StartNew(); var index = ArchiveFileBase.FromFile(indexFile); if (index == null) { continue; } stopwatch.Stop(); logger.LogInformation($"Loaded file {indexFile} in {stopwatch.ElapsedMilliseconds}ms"); dataFiles.Add(index); } foreach (var archiveFile in Directory.EnumerateFiles(basePath, "*.archive", SearchOption.AllDirectories)) { var stopwatch = Stopwatch.StartNew(); var archive = ArchiveFileBase.FromFile(archiveFile); if (archive == null) { continue; } stopwatch.Stop(); logger.LogInformation($"Loaded file {archiveFile} in {stopwatch.ElapsedMilliseconds}ms"); dataFiles.Add(archive); } ; //return new GameDataFiles(path, dataFiles.OfType<IndexFile>(), dataFiles.OfType<ArchiveFile>(), launcherPath, launcherHash, build); Build = build; _indexFiles = dataFiles.OfType <IndexFile>().ToList(); // Warm up file reading now. // ReSharper disable ReturnValueOfPureMethodIsNotUsed - Preloading data. Logger.LogInformation("Preloading index file data..."); var loadStopwatch = Stopwatch.StartNew(); var fileList = _indexFiles.SelectMany(i => i.GetFilesystemEntries()).ToList(); loadStopwatch.Stop(); Logger.LogInformation("Loaded {fileCount} file and directory information objects from {count} index files in {time}ms", fileList.Count, _indexFiles.Count, loadStopwatch.ElapsedMilliseconds); // ReSharper restore ReturnValueOfPureMethodIsNotUsed _archiveFiles = dataFiles.OfType <ArchiveFile>().ToList(); if (!additionalFiles.Any(x => string.Equals(x.FileName, "Launcher.exe", StringComparison.OrdinalIgnoreCase))) { var launcherPath = Path.Combine(basePath, "Wildstar.exe"); if (File.Exists(launcherPath)) { Logger.LogWarning("Launcher.exe not specified in additional files, injecting default launcher from {path}", launcherPath); additionalFiles.Insert(0, new AdditionalFile() { Path = launcherPath, FileName = "Launcher.exe", PublishBin = true }); } else { Logger.LogWarning("Launcher.exe not specified in additional files, and Wildstar.exe could not be found at {basePath}, patching will fail with Carbine/NCSoft launcher!", basePath); } } Logger.LogInformation("Adding index file hashes to lookup and public names"); foreach (var index in _indexFiles) { additionalFiles.Insert(0, new AdditionalFile() { Path = index.FileName, FileName = Path.GetFileName(index.FileName), PublishBin = true }); } Logger.LogInformation("Adding client files (Client, Client64, Launcher)"); foreach (var localFile in new[] { "Client", "Client64", "Launcher" }.Select(i => Path.Combine(basePath, i)) .Where(Directory.Exists) .SelectMany(i => Directory.EnumerateFiles(i, "*.*", SearchOption.AllDirectories))) { additionalFiles.Insert(0, new AdditionalFile() { Path = localFile, FileName = null, PublishBin = false }); //using (var fileStream = File.Open(localFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) //using (var sha = SHA1.Create()) //{ // var binHash = sha.ComputeHash(fileStream); // _lookup.Set(binHash, new LocalFile(localFile)); //} } Logger.LogInformation("Indexing additional configured files"); foreach (var file in additionalFiles) { var fileName = file.FileName ?? Path.GetFileName(file.Path); var hash = GetFileHash(file.Path); Logger.LogInformation("Adding file {name} ({filePath}) to index with hash {hash}", fileName, file.Path, BitConverter.ToString(hash).ToLower().Replace("-", "")); _lookup.Set(hash, new LocalFile(file.Path)); if (!file.PublishBin) { continue; } Logger.LogInformation("Adding file {fileName} info to .bin file lookup", fileName); _fileEntries.Add(new FileEntry() { FileName = fileName, FilePath = file.Path, Hash = hash }); } Logger.LogInformation("Indexing archive files"); foreach (var archive in _archiveFiles) { Logger.LogInformation("Indexing {count} hashes from {archive}", archive.FileData.Count(), Path.GetFileName(archive.FileName)); foreach (var dataEntry in archive.FileData) //_archiveFiles.SelectMany(i => i.FileData.Select(x => new DataEntryReference(i, x)))) { _lookup.Set(dataEntry.Hash, new DataEntryReference(archive, dataEntry)); //Debug.Assert(_lookup.Find(dataEntry.FileEntry.Hash) != null); } } }