{"id":51028336,"url":"https://github.com/ValveResourceFormat/ValvePak","last_synced_at":"2026-07-09T23:00:26.220Z","repository":{"id":140671982,"uuid":"68501384","full_name":"ValveResourceFormat/ValvePak","owner":"ValveResourceFormat","description":"📦 Fully fledged library to work with Valve's Pak archives in .NET","archived":false,"fork":false,"pushed_at":"2026-06-22T08:54:10.000Z","size":362,"stargazers_count":150,"open_issues_count":2,"forks_count":20,"subscribers_count":5,"default_branch":"master","last_synced_at":"2026-06-22T10:26:58.521Z","etag":null,"topics":["csharp","dotnet","source2","steam","valve","vpk"],"latest_commit_sha":null,"homepage":"https://www.nuget.org/packages/ValvePak/","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ValveResourceFormat.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["xPaw","kristiker"]}},"created_at":"2016-09-18T06:30:55.000Z","updated_at":"2026-06-22T08:54:08.000Z","dependencies_parsed_at":"2023-08-15T11:29:55.566Z","dependency_job_id":"80d748ef-8cfa-4088-af1a-ac53b796e152","html_url":"https://github.com/ValveResourceFormat/ValvePak","commit_stats":null,"previous_names":["valveresourceformat/valvepak","steamdatabase/valvepak"],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/ValveResourceFormat/ValvePak","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ValveResourceFormat%2FValvePak","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ValveResourceFormat%2FValvePak/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ValveResourceFormat%2FValvePak/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ValveResourceFormat%2FValvePak/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ValveResourceFormat","download_url":"https://codeload.github.com/ValveResourceFormat/ValvePak/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ValveResourceFormat%2FValvePak/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35314872,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-09T02:00:07.329Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csharp","dotnet","source2","steam","valve","vpk"],"created_at":"2026-06-21T22:00:22.294Z","updated_at":"2026-07-09T23:00:26.215Z","avatar_url":"https://github.com/ValveResourceFormat.png","language":"C#","funding_links":["https://github.com/sponsors/xPaw","https://github.com/sponsors/kristiker"],"categories":["⚙️ Engines"],"sub_categories":["Source (Valve)"],"readme":"\u003ch1 align=\"center\"\u003e\u003cimg src=\"./Misc/logo.png\" width=\"64\" height=\"64\" align=\"center\"\u003e Valve Pak for .NET\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/ValveResourceFormat/ValvePak/actions\" title=\"Build Status\"\u003e\u003cimg alt=\"Build Status\" src=\"https://img.shields.io/github/actions/workflow/status/ValveResourceFormat/ValvePak/ci.yml?logo=github\u0026label=Build\u0026logoColor=ffffff\u0026style=for-the-badge\u0026branch=master\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://www.nuget.org/packages/ValvePak/\" title=\"NuGet\"\u003e\u003cimg alt=\"NuGet\" src=\"https://img.shields.io/nuget/v/ValvePak.svg?logo=nuget\u0026label=NuGet\u0026logoColor=ffffff\u0026color=004880\u0026style=for-the-badge\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://app.codecov.io/gh/ValveResourceFormat/ValvePak\" title=\"Code Coverage\"\u003e\u003cimg alt=\"Code Coverage\" src=\"https://img.shields.io/codecov/c/github/ValveResourceFormat/ValvePak/master?logo=codecov\u0026label=Coverage\u0026logoColor=ffffff\u0026color=F01F7A\u0026style=for-the-badge\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\nA .NET library for reading and extracting VPK (Valve Pak) files, the uncompressed archive format used to package game content in Source and Source 2 engine games.\n\n## Usage\n\n```csharp\nusing var package = new Package();\n\n// Open a vpk file\npackage.Read(\"pak01_dir.vpk\");\n\n// Can also pass in a stream\npackage.Read(File.OpenRead(\"pak01_dir.vpk\"));\n\n// Optionally verify hashes and signatures of the file if there are any\npackage.VerifyHashes();\n\n// Find a file, this returns a PackageEntry\nvar file = package.FindEntry(\"path/to/file.txt\");\n\nif (file != null) {\n\t// Read a file to a byte array\n\tpackage.ReadEntry(file, out byte[] fileContents);\n\n\t// Inspect entry metadata\n\tConsole.WriteLine(file.GetFullPath());  // \"path/to/file.txt\"\n\tConsole.WriteLine(file.GetFileName());  // \"file.txt\"\n\tConsole.WriteLine(file.TotalLength);    // file size in bytes\n\tConsole.WriteLine(file.CRC32);          // CRC32 checksum\n}\n```\n\nDo note that files such as `pak01_001.vpk` are just data files, you have to open `pak01_dir.vpk`.\n\n## Extract all files\n\n```csharp\nusing var package = new Package();\npackage.Read(\"pak01_dir.vpk\");\n\nforeach (var group in package.Entries)\n{\n\tforeach (var entry in group.Value)\n\t{\n\t\tvar filePath = entry.GetFullPath();\n\n\t\tpackage.ReadEntry(entry, out byte[] data);\n\n\t\t// Create the directory if needed, then write the file\n\t\tDirectory.CreateDirectory(Path.GetDirectoryName(filePath));\n\t\tFile.WriteAllBytes(filePath, data);\n\t}\n}\n```\n\n## Create a VPK\n\n```csharp\nusing var package = new Package();\n\n// Add files to the package\npackage.AddFile(\"path/to/file.txt\", File.ReadAllBytes(\"file.txt\"));\npackage.AddFile(\"models/example.vmdl\", File.ReadAllBytes(\"example.vmdl\"));\n\n// Remove a file from the package\npackage.RemoveFile(package.FindEntry(\"path/to/file.txt\"));\n\n// Write the package to disk\npackage.Write(\"pak01_dir.vpk\");\n```\n\n## Optimize for many lookups\n\nBy default, `FindEntry` performs a linear scan. If you need to look up many files, call `OptimizeEntriesForBinarySearch()` before `Read()` to sort entries and use binary search instead. You can also pass `StringComparison.OrdinalIgnoreCase` for case-insensitive lookups.\n\n```csharp\nusing var package = new Package();\n\n// Call before Read() to enable binary search for FindEntry\npackage.OptimizeEntriesForBinarySearch();\npackage.Read(\"pak01_dir.vpk\");\n\n// FindEntry calls are now significantly faster\nvar file = package.FindEntry(\"path/to/file.txt\");\n```\n\n## Read into a user-provided buffer\n\n```csharp\nvar entry = package.FindEntry(\"path/to/file.txt\");\n\n// Allocate your own buffer (must be at least entry.TotalLength bytes)\nvar buffer = new byte[entry.TotalLength];\npackage.ReadEntry(entry, buffer, validateCrc: true);\n```\n\nUsing `ArrayPool` to avoid allocations when reading many files:\n\n```csharp\nvar entry = package.FindEntry(\"path/to/file.txt\");\n\nvar buffer = ArrayPool\u003cbyte\u003e.Shared.Rent((int)entry.TotalLength);\n\ntry\n{\n\tpackage.ReadEntry(entry, buffer, validateCrc: true);\n\n\t// Use buffer[..entry.TotalLength] here\n}\nfinally\n{\n\tArrayPool\u003cbyte\u003e.Shared.Return(buffer);\n}\n```\n\n## Stream-based access\n\n`GetMemoryMappedStreamIfPossible` returns a memory-mapped stream for large files (over 4 KiB) and a `MemoryStream` for smaller ones. This avoids reading the entire file into a byte array.\n\n```csharp\nvar entry = package.FindEntry(\"path/to/file.txt\");\n\nusing var stream = package.GetMemoryMappedStreamIfPossible(entry);\n```\n\n## Verification\n\n```csharp\nusing var package = new Package();\npackage.Read(\"pak01_dir.vpk\");\n\n// Verify MD5 hashes of the directory tree and whole file\npackage.VerifyHashes();\n\n// Verify MD5/Blake3 hashes of individual chunk files (pak01_000.vpk, pak01_001.vpk, ...)\npackage.VerifyChunkHashes();\n\n// Verify CRC32 checksums of every file in the package\npackage.VerifyFileChecksums();\n\n// Verify the RSA signature if the package is signed\nbool valid = package.IsSignatureValid();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FValveResourceFormat%2FValvePak","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FValveResourceFormat%2FValvePak","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FValveResourceFormat%2FValvePak/lists"}