Skip to content

Commit 2f89253

Browse files
csharp: update vpkpp bindings
1 parent a65e108 commit 2f89253

File tree

2 files changed

+116
-0
lines changed

2 files changed

+116
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
using System;
2+
using System.Runtime.InteropServices;
3+
4+
namespace vpkpp.Format
5+
{
6+
using EntryCallback = Action<string, Entry>;
7+
8+
internal static unsafe partial class Extern
9+
{
10+
internal static unsafe partial class HOG
11+
{
12+
[LibraryImport("sourcepp_vpkppc", EntryPoint = "vpkpp_hog_open")]
13+
public static partial void* Open([MarshalAs(UnmanagedType.LPStr)] string path, IntPtr callback);
14+
15+
[LibraryImport("sourcepp_vpkppc", EntryPoint = "vpkpp_hog_guid")]
16+
public static partial sourcepp.String GUID();
17+
}
18+
}
19+
20+
public class HOG : PackFile
21+
{
22+
private protected unsafe HOG(void* handle) : base(handle) {}
23+
24+
public new static HOG? Open(string path)
25+
{
26+
unsafe
27+
{
28+
var handle = Extern.HOG.Open(path, 0);
29+
return handle == null ? null : new HOG(handle);
30+
}
31+
}
32+
33+
public new static HOG? Open(string path, EntryCallback callback)
34+
{
35+
unsafe
36+
{
37+
EntryCallbackNative callbackNative = (path, entry) =>
38+
{
39+
callback(path, new Entry(entry, true));
40+
};
41+
var handle = Extern.HOG.Open(path, Marshal.GetFunctionPointerForDelegate(callbackNative));
42+
return handle == null ? null : new HOG(handle);
43+
}
44+
}
45+
46+
public static string GUID
47+
{
48+
get
49+
{
50+
unsafe
51+
{
52+
var str = Extern.HOG.GUID();
53+
return sourcepp.StringUtils.ConvertToStringAndDelete(ref str);
54+
}
55+
}
56+
}
57+
}
58+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
using System;
2+
using System.Runtime.InteropServices;
3+
4+
namespace vpkpp.Format
5+
{
6+
using EntryCallback = Action<string, Entry>;
7+
8+
internal static unsafe partial class Extern
9+
{
10+
internal static unsafe partial class VPP
11+
{
12+
[LibraryImport("sourcepp_vpkppc", EntryPoint = "vpkpp_vpp_open")]
13+
public static partial void* Open([MarshalAs(UnmanagedType.LPStr)] string path, IntPtr callback);
14+
15+
[LibraryImport("sourcepp_vpkppc", EntryPoint = "vpkpp_vpp_guid")]
16+
public static partial sourcepp.String GUID();
17+
}
18+
}
19+
20+
public class VPP : PackFile
21+
{
22+
private protected unsafe VPP(void* handle) : base(handle) {}
23+
24+
public new static VPP? Open(string path)
25+
{
26+
unsafe
27+
{
28+
var handle = Extern.VPP.Open(path, 0);
29+
return handle == null ? null : new VPP(handle);
30+
}
31+
}
32+
33+
public new static VPP? Open(string path, EntryCallback callback)
34+
{
35+
unsafe
36+
{
37+
EntryCallbackNative callbackNative = (path, entry) =>
38+
{
39+
callback(path, new Entry(entry, true));
40+
};
41+
var handle = Extern.VPP.Open(path, Marshal.GetFunctionPointerForDelegate(callbackNative));
42+
return handle == null ? null : new VPP(handle);
43+
}
44+
}
45+
46+
public static string GUID
47+
{
48+
get
49+
{
50+
unsafe
51+
{
52+
var str = Extern.VPP.GUID();
53+
return sourcepp.StringUtils.ConvertToStringAndDelete(ref str);
54+
}
55+
}
56+
}
57+
}
58+
}

0 commit comments

Comments
 (0)