MoonTools.NETPhysFS/SharpPhysFS/Interop.cs

205 lines
9.3 KiB
C#
Raw Normal View History

2016-01-27 17:57:53 +00:00
using System;
2016-01-27 22:04:37 +00:00
using System.Linq;
2016-01-27 17:57:53 +00:00
using System.Runtime.InteropServices;
namespace SharpPhysFS
2016-01-27 17:57:53 +00:00
{
2017-05-26 11:14:23 +00:00
[UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
2016-01-27 17:57:53 +00:00
public delegate int InitDelegate();
2017-05-26 11:14:23 +00:00
[UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
2016-01-27 17:57:53 +00:00
public delegate void DeinitDelegate();
2017-05-26 11:14:23 +00:00
[UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
2016-01-27 17:57:53 +00:00
public delegate IntPtr MallocDelegate(ulong size);
2017-05-26 11:14:23 +00:00
[UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
2016-01-27 17:57:53 +00:00
public delegate IntPtr ReallocDelegate(IntPtr ptr, ulong size);
2017-05-26 11:14:23 +00:00
[UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
2016-01-27 17:57:53 +00:00
public delegate void FreeDelegate(IntPtr ptr);
2017-05-26 11:14:23 +00:00
[UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
2016-01-27 17:57:53 +00:00
public delegate void StringCallback(IntPtr data, string str);
2017-05-26 11:14:23 +00:00
[UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
2016-01-27 17:57:53 +00:00
public delegate void EnumFilesCallback(IntPtr data, string origdir, string fname);
[StructLayout(LayoutKind.Sequential)]
public struct ArchiveInfo
{
[MarshalAs(UnmanagedType.LPStr)]
public string extension;
[MarshalAs(UnmanagedType.LPStr)]
public string description;
[MarshalAs(UnmanagedType.LPStr)]
public string author;
[MarshalAs(UnmanagedType.LPStr)]
public string url;
}
[StructLayout(LayoutKind.Sequential)]
public struct Version
{
public byte major;
public byte minor;
public byte patch;
}
[StructLayout(LayoutKind.Sequential)]
2017-05-28 12:47:02 +00:00
public struct Allocator
2016-01-27 17:57:53 +00:00
{
[MarshalAs(UnmanagedType.FunctionPtr)]
public InitDelegate Init;
[MarshalAs(UnmanagedType.FunctionPtr)]
public DeinitDelegate Deinit;
[MarshalAs(UnmanagedType.FunctionPtr)]
public MallocDelegate Malloc;
[MarshalAs(UnmanagedType.FunctionPtr)]
public ReallocDelegate Realloc;
[MarshalAs(UnmanagedType.FunctionPtr)]
public FreeDelegate Free;
}
2017-05-26 11:14:23 +00:00
static class Interop
2016-01-27 17:57:53 +00:00
{
2020-01-17 01:06:12 +00:00
private const string s_nativeLibName = "physfs";
[DllImport(s_nativeLibName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
2017-05-26 11:14:23 +00:00
public static extern void PHYSFS_getLinkedVersion(ref Version v);
2016-01-27 17:57:53 +00:00
2020-01-17 01:06:12 +00:00
[DllImport(s_nativeLibName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
2017-05-26 11:14:23 +00:00
public static extern int PHYSFS_init(string argv0);
2016-01-27 17:57:53 +00:00
2020-01-17 01:06:12 +00:00
[DllImport(s_nativeLibName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
2017-05-26 11:14:23 +00:00
public static extern int PHYSFS_deinit();
2016-01-27 17:57:53 +00:00
2020-01-17 01:06:12 +00:00
[DllImport(s_nativeLibName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
2017-05-26 11:14:23 +00:00
public static extern IntPtr PHYSFS_supportedArchiveTypes();
2016-01-27 17:57:53 +00:00
2020-01-17 01:06:12 +00:00
[DllImport(s_nativeLibName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
2017-05-26 11:14:23 +00:00
public static extern void PHYSFS_freeList(IntPtr h);
2016-01-27 17:57:53 +00:00
2020-01-17 01:06:12 +00:00
[DllImport(s_nativeLibName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
2017-05-26 11:14:23 +00:00
public static extern IntPtr PHYSFS_getLastError();
2016-01-29 19:04:01 +00:00
2020-01-17 01:06:12 +00:00
[DllImport(s_nativeLibName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
2017-05-26 11:14:23 +00:00
public static extern IntPtr PHYSFS_getDirSeparator();
2016-01-29 19:04:01 +00:00
2020-01-17 01:06:12 +00:00
[DllImport(s_nativeLibName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
2017-05-26 11:14:23 +00:00
public static extern void PHYSFS_permitSymbolicLinks(int permit);
2016-01-29 19:04:01 +00:00
2020-01-17 01:06:12 +00:00
[DllImport(s_nativeLibName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
2017-05-26 11:14:23 +00:00
public static extern IntPtr PHYSFS_getCdRomDirs();
2016-01-27 17:57:53 +00:00
2020-01-17 01:06:12 +00:00
[DllImport(s_nativeLibName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
2017-05-26 11:14:23 +00:00
public static extern IntPtr PHYSFS_getBaseDir();
2020-01-17 01:06:12 +00:00
[DllImport(s_nativeLibName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
2017-05-26 11:14:23 +00:00
public static extern IntPtr PHYSFS_getUserDir();
2020-01-17 01:06:12 +00:00
[DllImport(s_nativeLibName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
2017-05-26 11:14:23 +00:00
public static extern IntPtr PHYSFS_getWriteDir();
2020-01-17 01:06:12 +00:00
[DllImport(s_nativeLibName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
2017-05-26 11:14:23 +00:00
public static extern int PHYSFS_setWriteDir(string s);
2020-01-17 01:06:12 +00:00
[DllImport(s_nativeLibName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
2017-05-26 11:14:23 +00:00
public static extern int PHYSFS_addToSearchPath(string s, int i);
2020-01-17 01:06:12 +00:00
[DllImport(s_nativeLibName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
2017-05-26 11:14:23 +00:00
public static extern int PHYSFS_removeFromSearchPath(string s);
2020-01-17 01:06:12 +00:00
[DllImport(s_nativeLibName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
2017-05-26 11:14:23 +00:00
public static extern IntPtr PHYSFS_getSearchPath();
2020-01-17 01:06:12 +00:00
[DllImport(s_nativeLibName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
2017-05-26 11:14:23 +00:00
public static extern int PHYSFS_setSaneConfig(string s1, string s2, string s3, int i1, int i2);
2020-01-17 01:06:12 +00:00
[DllImport(s_nativeLibName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
2017-05-26 11:14:23 +00:00
public static extern int PHYSFS_mkdir(string s);
2020-01-17 01:06:12 +00:00
[DllImport(s_nativeLibName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
2017-05-26 11:14:23 +00:00
public static extern int PHYSFS_delete(string s);
2020-01-17 01:06:12 +00:00
[DllImport(s_nativeLibName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
2017-05-26 11:14:23 +00:00
public static extern IntPtr PHYSFS_getRealDir(string s);
2020-01-17 01:06:12 +00:00
[DllImport(s_nativeLibName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
2017-05-26 11:14:23 +00:00
public static extern IntPtr PHYSFS_enumerateFiles(string s);
2020-01-17 01:06:12 +00:00
[DllImport(s_nativeLibName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
2017-05-26 11:14:23 +00:00
public static extern int PHYSFS_exists(string s);
2020-01-17 01:06:12 +00:00
[DllImport(s_nativeLibName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
2017-05-26 11:14:23 +00:00
public static extern int PHYSFS_isDirectory(string s);
2020-01-17 01:06:12 +00:00
[DllImport(s_nativeLibName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
2017-05-26 11:14:23 +00:00
public static extern int PHYSFS_isSymbolicLink(string s);
2020-01-17 01:06:12 +00:00
[DllImport(s_nativeLibName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
2017-05-26 11:14:23 +00:00
public static extern long PHYSFS_getLastModTime(string s);
2020-01-17 01:06:12 +00:00
[DllImport(s_nativeLibName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
2017-05-26 11:14:23 +00:00
public static extern IntPtr PHYSFS_openWrite(string s);
2020-01-17 01:06:12 +00:00
[DllImport(s_nativeLibName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
2017-05-26 11:14:23 +00:00
public static extern IntPtr PHYSFS_openAppend(string s);
2020-01-17 01:06:12 +00:00
[DllImport(s_nativeLibName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
2017-05-26 11:14:23 +00:00
public static extern IntPtr PHYSFS_openRead(string s);
2020-01-17 01:06:12 +00:00
[DllImport(s_nativeLibName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
2017-05-26 11:14:23 +00:00
public static extern int PHYSFS_close(IntPtr ptr);
2020-01-17 01:06:12 +00:00
[DllImport(s_nativeLibName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
2017-05-26 11:14:23 +00:00
public static extern long PHYSFS_read(IntPtr ptr1, IntPtr ptr2, uint i1, uint i2);
2020-01-17 01:06:12 +00:00
[DllImport(s_nativeLibName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
2017-05-26 11:14:23 +00:00
public static extern long PHYSFS_write(IntPtr ptr1, IntPtr ptr2, uint i1, uint i2);
2020-01-17 01:06:12 +00:00
[DllImport(s_nativeLibName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
2017-05-26 11:14:23 +00:00
public static extern int PHYSFS_eof(IntPtr ptr);
2020-01-17 01:06:12 +00:00
[DllImport(s_nativeLibName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
2017-05-26 11:14:23 +00:00
public static extern long PHYSFS_tell(IntPtr ptr);
2020-01-17 01:06:12 +00:00
[DllImport(s_nativeLibName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
2017-05-26 11:14:23 +00:00
public static extern int PHYSFS_seek(IntPtr ptr, ulong u);
2020-01-17 01:06:12 +00:00
[DllImport(s_nativeLibName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
2017-05-26 11:14:23 +00:00
public static extern long PHYSFS_fileLength(IntPtr ptr);
2020-01-17 01:06:12 +00:00
[DllImport(s_nativeLibName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
2017-05-26 11:14:23 +00:00
public static extern int PHYSFS_setBuffer(IntPtr ptr, ulong u);
2020-01-17 01:06:12 +00:00
[DllImport(s_nativeLibName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
2017-05-26 11:14:23 +00:00
public static extern int PHYSFS_flush(IntPtr ptr);
2020-01-17 01:06:12 +00:00
[DllImport(s_nativeLibName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
2017-05-26 11:14:23 +00:00
public static extern int PHYSFS_isInit();
2020-01-17 01:06:12 +00:00
[DllImport(s_nativeLibName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
2017-05-26 11:14:23 +00:00
public static extern int PHYSFS_symbolicLinksPermitted();
2020-01-17 01:06:12 +00:00
[DllImport(s_nativeLibName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
2017-05-26 11:14:23 +00:00
public static extern int PHYSFS_setAllocator(Allocator alloc);
2020-01-17 01:06:12 +00:00
[DllImport(s_nativeLibName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
2017-05-26 11:14:23 +00:00
public static extern int PHYSFS_mount(string s1, string s2, int i);
2020-01-17 01:06:12 +00:00
[DllImport(s_nativeLibName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
2017-05-26 11:14:23 +00:00
public static extern IntPtr PHYSFS_getMountPoint(string s);
2020-01-17 01:06:12 +00:00
[DllImport(s_nativeLibName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
2017-05-26 11:14:23 +00:00
public static extern void PHYSFS_getCdRomDirsCallback(StringCallback c, IntPtr p);
2020-01-17 01:06:12 +00:00
[DllImport(s_nativeLibName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
2017-05-26 11:14:23 +00:00
public static extern void PHYSFS_getSearchPathCallback(StringCallback c, IntPtr p);
2020-01-17 01:06:12 +00:00
[DllImport(s_nativeLibName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
2017-05-26 11:14:23 +00:00
public static extern void PHYSFS_enumerateFilesCallback(string s, EnumFilesCallback c, IntPtr p);
2016-01-27 17:57:53 +00:00
}
}