static void Main(string[] args) { if (args.Length != 3) { Console.WriteLine("Usage: VpkExtract <vpk_file> <output_dir> <version>"); return; } var archive = new VpkArchive(); archive.Load(args[0], args[2] == "1" ? VpkVersions.Versions.V1 : VpkVersions.Versions.V2); foreach (var directory in archive.Directories) { foreach (var entry in directory.Entries) { string dirPath = Path.Combine(args[1], entry.Path); Directory.CreateDirectory(dirPath); string path = entry.Path + "/" + entry.Filename + "." + entry.Extension; Console.WriteLine(path); path = Path.Combine(args[1], path); File.WriteAllBytes(path, entry.Data); } } Console.WriteLine("Done"); }
static void Main(string[] args) { var archive = new VpkArchive(); archive.Load(@"G:\Steam\SteamApps\common\dota 2 beta\dota\pak01_dir.vpk"); //foreach(var dir in archive.Directories) // foreach(var entry in dir.Entries) // if (entry.HasPreloadData) // { // } Console.WriteLine("Done"); Console.ReadLine(); }
static void Main(string[] args) { using (var testVpkArchive = new VpkArchive()) { testVpkArchive.Load(@"E:\Games\Steam\steamapps\common\dota 2 beta\game\dota\pak01_dir.vpk", VpkVersions.Versions.V2); foreach (var dir in testVpkArchive.Directories) { foreach (var entry in dir.Entries) { //Console.WriteLine( Path.Combine( entry.Path , Path.ChangeExtension( entry.Filename , entry.Extension ) ) ); //var stream = entry.ReadAnyDataStream(); } } //try to find items_game.txt var itemsEntry = testVpkArchive.Directories .Where(x => x.Path.StartsWith("scripts") && x.Entries.Find(y => y.Filename.Contains("items_game")) != null) .Select(x => x.Entries.Find(y => y.Filename.Contains("items_game"))) .First(); using (var fileStream = File.OpenWrite(itemsEntry.Filename + "." + itemsEntry.Extension)) { itemsEntry.CopyDataStreamTo(fileStream); } /* * using( var stream = itemsEntry.ReadAnyDataStream() ) * using( var fileStream = File.OpenWrite( itemsEntry.Filename + "." + itemsEntry.Extension ) ) * { * stream.Position = 0; * stream.CopyTo( fileStream ); * } */ } Console.WriteLine("Done"); Console.ReadLine(); }
public static void Do() { var archive = new VpkArchive(); Console.WriteLine(File.Exists("csgo/pak01_dir.vpk")); Console.WriteLine("1"); archive.Load("csgo/pak01_dir.vpk"); Console.WriteLine("2"); Console.WriteLine(archive.Directories.Count); foreach (var directory in archive.Directories) { foreach (var entry in directory.Entries) { Console.WriteLine(entry.ToString()); } } }
public static void Process() { const string heroesMini = @"Dota 2\Heroes\Mini\"; const string heroesLandscape = @"Dota 2\Heroes\Landscape\"; const string heroesPortrait = @"Dota 2\Heroes\Portrait\"; const string items = @"Dota 2\Items\"; const string spells = @"Dota 2\Spells\"; string[] directories = { heroesMini, heroesLandscape, heroesPortrait, items, spells }; Helper.BuildDirectoryTree(directories); // Get the path of the source INIFile ini = new INIFile(Globals.Paths.ConfigurationFile); string sourcePath = ini.INIReadValue("Game Paths", "Dota 2"); string vpkPath = Path.Combine(sourcePath, @"dota\pak01_dir.vpk"); const string archivePrepend = @"resource/flash3/images/{0}"; // Get the source string[] valvePackages = { "heroes", @"heroes\selection", "miniheroes", "spellicons", "items" }; foreach (string valvePackage in valvePackages) { var valveArchive = new VpkArchive(); valveArchive.Load(vpkPath); foreach (var directory in valveArchive.Directories) { string rootDirectory = string.Format(archivePrepend, valvePackage); if (directory.ToString().Contains(rootDirectory)) { foreach (var entry in directory.Entries) { string destPath = Path.Combine(Globals.Paths.Assets, @"Source\Dota 2", entry.ToString().Replace("resource/flash3/images/", "")); FileInfo destInfo = new FileInfo(destPath); string destDirectory = destInfo.Directory.ToString(); if (!Directory.Exists(destDirectory)) { Directory.CreateDirectory(destDirectory); Console.WriteLine("Creating directory {0}", destDirectory); } if (Directory.Exists(destDirectory)) { Console.WriteLine("Extracting {0}", destPath); File.WriteAllBytes(destPath, entry.Data); } } } } } // Copy the rest of the source assets // Copy jobs take the form { string output path, { string start path, bool recursion flag, string search pattern, string exclude pattern } } List <CopyJob> copyJobs = new List <CopyJob> { new CopyJob(heroesPortrait, Path.Combine(Globals.Paths.Assets, @"Source\Dota 2\heroes\selection"), true, "npc_dota_hero_*.png", null), new CopyJob(heroesLandscape, Path.Combine(Globals.Paths.Assets, @"Source\Dota 2\heroes"), false, "*.png", null), new CopyJob(heroesMini, Path.Combine(Globals.Paths.Assets, @"Source\Dota 2\miniheroes"), true, "*.png", null), new CopyJob(spells, Path.Combine(Globals.Paths.Assets, @"Source\Dota 2\spellicons"), true, "*.png", null), new CopyJob(items, Path.Combine(Globals.Paths.Assets, @"Source\Dota 2\items"), true, "*.png", null) }; Helper.BatchFileCopy(copyJobs); // Rename all the things Helper.BatchFileRename("Dota 2"); // Scale all the things // Scaling jobs take the form { string start path, string search pattern, string exclude pattern } List <ScalingJob> scalingJobs = new List <ScalingJob> { new ScalingJob(heroesLandscape, "*.png"), new ScalingJob(heroesMini, "*.png"), new ScalingJob(heroesPortrait, "*.png"), new ScalingJob(items, "*.png"), new ScalingJob(spells, "*.png") }; Helper.BatchIMScale(scalingJobs); }