public static void LoadFromVPK(string vpkPath) { if (!Directory.Exists("cache")) { Directory.CreateDirectory("cache"); } string path = Properties.Settings.Default.DotaDir + Path.DirectorySeparatorChar + VPKPath; HLLib.hlInitialize(); // Get the package type from the filename extension. HLLib.HLPackageType PackageType = HLLib.hlGetPackageTypeFromName(path); HLLib.HLFileMode OpenMode = HLLib.HLFileMode.HL_MODE_READ | //HLLib.HLFileMode.HL_MODE_QUICK_FILEMAPPING | HLLib.HLFileMode.HL_MODE_VOLATILE; uint PackageID; ErrorCheck(HLLib.hlCreatePackage(PackageType, out PackageID)); ErrorCheck(HLLib.hlBindPackage(PackageID)); ErrorCheck(HLLib.hlPackageOpenFile(path, (uint)OpenMode)); }
public PackageSystem(List <string> packages) { _rootNode = new PackageNode() { Name = "root", Directory = true }; HLLib.hlInitialize(); foreach (var package in packages) { if (Directory.Exists(package)) { FindDirFiles(package, _rootNode); continue; } HLLib.HLPackageType type = HLLib.hlGetPackageTypeFromName(package); uint packagePointer; if (!HLLib.hlCreatePackage(type, out packagePointer)) { throw new Exception("Can't load package: " + HLLib.hlGetString(HLLib.HLOption.HL_ERROR_SHORT_FORMATED)); } HLLib.hlBindPackage(packagePointer); if (!HLLib.hlPackageOpenFile(package, (uint)HLLib.HLFileMode.HL_MODE_READ)) { throw new Exception("Can't load package: " + HLLib.hlGetString(HLLib.HLOption.HL_ERROR_SHORT_FORMATED)); } _rootNode.FileSize = 0; var rootItems = HLLib.hlFolderGetCount(HLLib.hlPackageGetRoot()); for (uint i = 0; i < rootItems; i++) { var item = HLLib.hlFolderGetItem(HLLib.hlPackageGetRoot(), i); uint size; HLLib.hlItemGetSize(item, out size); _rootNode.FileSize += size; } FindFiles(HLLib.hlPackageGetRoot(), _rootNode, packagePointer); //HLLib.hlPackageClose(); } }
public static void OpenVPK() { string path = GlobalSettings.DotaDirectory + Path.DirectorySeparatorChar + VPKPath; HLLib.hlInitialize(); // Get the package type from the filename extension. HLLib.HLPackageType PackageType = HLLib.hlGetPackageTypeFromName(path); HLLib.HLFileMode OpenMode = HLLib.HLFileMode.HL_MODE_READ | //HLLib.HLFileMode.HL_MODE_QUICK_FILEMAPPING | HLLib.HLFileMode.HL_MODE_VOLATILE; uint PackageID; ErrorCheck(HLLib.hlCreatePackage(PackageType, out PackageID)); ErrorCheck(HLLib.hlBindPackage(PackageID)); ErrorCheck(HLLib.hlPackageOpenFile(path, (uint)OpenMode)); }