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;
|
|
|
|
|
|
2016-01-29 14:22:44 +00:00
|
|
|
|
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
|
|
|
|
{
|
2017-05-26 11:14:23 +00:00
|
|
|
|
[DllImport("physfs.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
|
|
|
public static extern void PHYSFS_getLinkedVersion(ref Version v);
|
2016-01-27 17:57:53 +00:00
|
|
|
|
|
2017-05-26 11:14:23 +00:00
|
|
|
|
[DllImport("physfs.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
|
|
|
public static extern int PHYSFS_init(string argv0);
|
2016-01-27 17:57:53 +00:00
|
|
|
|
|
2017-05-26 11:14:23 +00:00
|
|
|
|
[DllImport("physfs.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
|
|
|
public static extern int PHYSFS_deinit();
|
2016-01-27 17:57:53 +00:00
|
|
|
|
|
2017-05-26 11:14:23 +00:00
|
|
|
|
[DllImport("physfs.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
|
|
|
public static extern IntPtr PHYSFS_supportedArchiveTypes();
|
2016-01-27 17:57:53 +00:00
|
|
|
|
|
2017-05-26 11:14:23 +00:00
|
|
|
|
[DllImport("physfs.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
|
|
|
public static extern void PHYSFS_freeList(IntPtr h);
|
2016-01-27 17:57:53 +00:00
|
|
|
|
|
2017-05-26 11:14:23 +00:00
|
|
|
|
[DllImport("physfs.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
|
|
|
public static extern IntPtr PHYSFS_getLastError();
|
2016-01-29 19:04:01 +00:00
|
|
|
|
|
2017-05-26 11:14:23 +00:00
|
|
|
|
[DllImport("physfs.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
|
|
|
public static extern IntPtr PHYSFS_getDirSeparator();
|
2016-01-29 19:04:01 +00:00
|
|
|
|
|
2017-05-26 11:14:23 +00:00
|
|
|
|
[DllImport("physfs.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
|
|
|
public static extern void PHYSFS_permitSymbolicLinks(int permit);
|
2016-01-29 19:04:01 +00:00
|
|
|
|
|
2017-05-26 11:14:23 +00:00
|
|
|
|
[DllImport("physfs.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
|
|
|
public static extern IntPtr PHYSFS_getCdRomDirs();
|
2016-01-27 17:57:53 +00:00
|
|
|
|
|
2017-05-26 11:14:23 +00:00
|
|
|
|
[DllImport("physfs.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
|
|
|
public static extern IntPtr PHYSFS_getBaseDir();
|
|
|
|
|
|
|
|
|
|
[DllImport("physfs.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
|
|
|
public static extern IntPtr PHYSFS_getUserDir();
|
|
|
|
|
|
|
|
|
|
[DllImport("physfs.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
|
|
|
public static extern IntPtr PHYSFS_getWriteDir();
|
|
|
|
|
|
|
|
|
|
[DllImport("physfs.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
|
|
|
public static extern int PHYSFS_setWriteDir(string s);
|
|
|
|
|
|
|
|
|
|
[DllImport("physfs.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
|
|
|
public static extern int PHYSFS_addToSearchPath(string s, int i);
|
|
|
|
|
|
|
|
|
|
[DllImport("physfs.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
|
|
|
public static extern int PHYSFS_removeFromSearchPath(string s);
|
|
|
|
|
|
|
|
|
|
[DllImport("physfs.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
|
|
|
public static extern IntPtr PHYSFS_getSearchPath();
|
|
|
|
|
|
|
|
|
|
[DllImport("physfs.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
|
|
|
public static extern int PHYSFS_setSaneConfig(string s1, string s2, string s3, int i1, int i2);
|
|
|
|
|
|
|
|
|
|
[DllImport("physfs.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
|
|
|
public static extern int PHYSFS_mkdir(string s);
|
|
|
|
|
|
|
|
|
|
[DllImport("physfs.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
|
|
|
public static extern int PHYSFS_delete(string s);
|
|
|
|
|
|
|
|
|
|
[DllImport("physfs.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
|
|
|
public static extern IntPtr PHYSFS_getRealDir(string s);
|
|
|
|
|
|
|
|
|
|
[DllImport("physfs.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
|
|
|
public static extern IntPtr PHYSFS_enumerateFiles(string s);
|
|
|
|
|
|
|
|
|
|
[DllImport("physfs.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
|
|
|
public static extern int PHYSFS_exists(string s);
|
|
|
|
|
|
|
|
|
|
[DllImport("physfs.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
|
|
|
public static extern int PHYSFS_isDirectory(string s);
|
|
|
|
|
|
|
|
|
|
[DllImport("physfs.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
|
|
|
public static extern int PHYSFS_isSymbolicLink(string s);
|
|
|
|
|
|
|
|
|
|
[DllImport("physfs.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
|
|
|
public static extern long PHYSFS_getLastModTime(string s);
|
|
|
|
|
|
|
|
|
|
[DllImport("physfs.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
|
|
|
public static extern IntPtr PHYSFS_openWrite(string s);
|
|
|
|
|
|
|
|
|
|
[DllImport("physfs.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
|
|
|
public static extern IntPtr PHYSFS_openAppend(string s);
|
|
|
|
|
|
|
|
|
|
[DllImport("physfs.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
|
|
|
public static extern IntPtr PHYSFS_openRead(string s);
|
|
|
|
|
|
|
|
|
|
[DllImport("physfs.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
|
|
|
public static extern int PHYSFS_close(IntPtr ptr);
|
|
|
|
|
|
|
|
|
|
[DllImport("physfs.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
|
|
|
public static extern long PHYSFS_read(IntPtr ptr1, IntPtr ptr2, uint i1, uint i2);
|
|
|
|
|
|
|
|
|
|
[DllImport("physfs.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
|
|
|
public static extern long PHYSFS_write(IntPtr ptr1, IntPtr ptr2, uint i1, uint i2);
|
|
|
|
|
|
|
|
|
|
[DllImport("physfs.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
|
|
|
public static extern int PHYSFS_eof(IntPtr ptr);
|
|
|
|
|
|
|
|
|
|
[DllImport("physfs.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
|
|
|
public static extern long PHYSFS_tell(IntPtr ptr);
|
|
|
|
|
|
|
|
|
|
[DllImport("physfs.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
|
|
|
public static extern int PHYSFS_seek(IntPtr ptr, ulong u);
|
|
|
|
|
|
|
|
|
|
[DllImport("physfs.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
|
|
|
public static extern long PHYSFS_fileLength(IntPtr ptr);
|
|
|
|
|
|
|
|
|
|
[DllImport("physfs.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
|
|
|
public static extern int PHYSFS_setBuffer(IntPtr ptr, ulong u);
|
|
|
|
|
|
|
|
|
|
[DllImport("physfs.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
|
|
|
public static extern int PHYSFS_flush(IntPtr ptr);
|
|
|
|
|
|
|
|
|
|
[DllImport("physfs.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
|
|
|
public static extern int PHYSFS_isInit();
|
|
|
|
|
|
|
|
|
|
[DllImport("physfs.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
|
|
|
public static extern int PHYSFS_symbolicLinksPermitted();
|
|
|
|
|
|
|
|
|
|
[DllImport("physfs.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
|
|
|
public static extern int PHYSFS_setAllocator(Allocator alloc);
|
|
|
|
|
|
|
|
|
|
[DllImport("physfs.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
|
|
|
public static extern int PHYSFS_mount(string s1, string s2, int i);
|
|
|
|
|
|
|
|
|
|
[DllImport("physfs.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
|
|
|
public static extern IntPtr PHYSFS_getMountPoint(string s);
|
|
|
|
|
|
|
|
|
|
[DllImport("physfs.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
|
|
|
public static extern void PHYSFS_getCdRomDirsCallback(StringCallback c, IntPtr p);
|
|
|
|
|
|
|
|
|
|
[DllImport("physfs.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
|
|
|
public static extern void PHYSFS_getSearchPathCallback(StringCallback c, IntPtr p);
|
|
|
|
|
|
|
|
|
|
[DllImport("physfs.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
|
|
|
|
public static extern void PHYSFS_enumerateFilesCallback(string s, EnumFilesCallback c, IntPtr p);
|
2016-01-27 17:57:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|