You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+124-7Lines changed: 124 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,13 +1,14 @@
1
-
<h1><imgsrc="./Misc/logo.png"width="64"align="center"> Valve Pak (vpk) for .NET</h1>
1
+
<h1align="center"><imgsrc="./Misc/logo.png"width="64"height="64"align="center"> Valve Pak for .NET</h1>
2
2
3
-
[](https://github.com/ValveResourceFormat/ValvePak/actions)
VPK (Valve Pak) files are uncompressed archives used to package game content.
8
-
This library allows you to read and extract files out of these paks.
9
+
A .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.
9
10
10
-
Usage:
11
+
## Usage
11
12
12
13
```csharp
13
14
usingvarpackage=newPackage();
@@ -27,7 +28,123 @@ var file = package.FindEntry("path/to/file.txt");
By 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.
82
+
83
+
```csharp
84
+
usingvarpackage=newPackage();
85
+
86
+
// Call before Read() to enable binary search for FindEntry
87
+
package.OptimizeEntriesForBinarySearch();
88
+
package.Read("pak01_dir.vpk");
89
+
90
+
// FindEntry calls are now significantly faster
91
+
varfile=package.FindEntry("path/to/file.txt");
92
+
```
93
+
94
+
## Read into a user-provided buffer
95
+
96
+
```csharp
97
+
varentry=package.FindEntry("path/to/file.txt");
98
+
99
+
// Allocate your own buffer (must be at least entry.TotalLength bytes)
`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.
0 commit comments