1 /* PhysFS_DLL - (c)2003 Gregory S. Read
\r
2 * Internal class that provides direct access to the PhysFS DLL. It is
\r
3 * not accessible outside of the PhysFS.NET assembly.
\r
5 using System.Collections;
\r
6 using System.Runtime.InteropServices;
\r
10 internal class PhysFS_DLL
\r
12 /* Static constructor
\r
13 * Initializes the PhysFS API before any method is called in this class. This
\r
14 * relieves the user from having to explicitly initialize the API.
\r
20 * PhysFSException - An error occured in the PhysFS API
\r
24 if(PHYSFS_init("") == 0)
\r
25 throw new PhysFSException();
\r
29 * Converts a C-style string array into a .NET managed string array
\r
31 * C-style string array pointer returned from PhysFS
\r
33 * .NET managed string array
\r
37 public unsafe static string[] BytePPToArray(byte **bytearray)
\r
42 ArrayList MyArrayList = new ArrayList();
\r
45 for(ptr = bytearray; *ptr != null; ptr++)
48 for(c = *ptr; *c != 0; c++)
50 tempstr += (char)*c;
\r
53 // Add string to our list
\r
54 MyArrayList.Add(tempstr);
\r
57 // Return a normal array of the list
\r
58 RetArray = new string[MyArrayList.Count];
\r
59 MyArrayList.CopyTo(RetArray, 0);
\r
63 // Name of DLL to import
\r
64 private const string PHYSFS_DLLNAME = "physfs.dll";
\r
66 // DLL import declarations
\r
67 [DllImport(PHYSFS_DLLNAME)] public static extern int PHYSFS_init(string argv0);
\r
68 [DllImport(PHYSFS_DLLNAME)] public static extern int PHYSFS_deinit();
\r
69 [DllImport(PHYSFS_DLLNAME)] public static extern unsafe void PHYSFS_freeList(void *listVar);
70 [DllImport(PHYSFS_DLLNAME)] public static extern string PHYSFS_getLastError();
71 [DllImport(PHYSFS_DLLNAME)] public static extern string PHYSFS_getDirSeparator();
72 [DllImport(PHYSFS_DLLNAME)] public static extern void PHYSFS_permitSymbolicLinks(int allow);
73 [DllImport(PHYSFS_DLLNAME)] public static extern unsafe byte** PHYSFS_getCdRomDirs();
\r
74 [DllImport(PHYSFS_DLLNAME)] public static extern string PHYSFS_getBaseDir();
75 [DllImport(PHYSFS_DLLNAME)] public static extern string PHYSFS_getUserDir();
76 [DllImport(PHYSFS_DLLNAME)] public static extern string PHYSFS_getWriteDir();
77 [DllImport(PHYSFS_DLLNAME)] public static extern int PHYSFS_setWriteDir(string newDir);
78 [DllImport(PHYSFS_DLLNAME)] public static extern int PHYSFS_addToSearchPath(string newDir, int appendToPath);
79 [DllImport(PHYSFS_DLLNAME)] public static extern int PHYSFS_removeFromSearchPath(string oldDir);
80 [DllImport(PHYSFS_DLLNAME)] public static extern unsafe byte** PHYSFS_getSearchPath();
81 [DllImport(PHYSFS_DLLNAME)] public static extern int PHYSFS_setSaneConfig(string organization,
86 [DllImport(PHYSFS_DLLNAME)] public static extern int PHYSFS_mkdir(string dirName);
87 [DllImport(PHYSFS_DLLNAME)] public static extern int PHYSFS_delete(string filename);
88 [DllImport(PHYSFS_DLLNAME)] public static extern string PHYSFS_getRealDir(string filename);
89 [DllImport(PHYSFS_DLLNAME)] public static extern unsafe byte** PHYSFS_enumerateFiles(string dir);
\r
90 [DllImport(PHYSFS_DLLNAME)] public static extern int PHYSFS_exists(string fname);
91 [DllImport(PHYSFS_DLLNAME)] public static extern int PHYSFS_isDirectory(string fname);
92 [DllImport(PHYSFS_DLLNAME)] public static extern int PHYSFS_isSymbolicLink(string fname);
93 [DllImport(PHYSFS_DLLNAME)] public static extern unsafe void* PHYSFS_openWrite(string filename);
94 [DllImport(PHYSFS_DLLNAME)] public static extern unsafe void* PHYSFS_openAppend(string filename);
95 [DllImport(PHYSFS_DLLNAME)] public static extern unsafe void* PHYSFS_openRead(string filename);
96 [DllImport(PHYSFS_DLLNAME)] public static extern unsafe int PHYSFS_close(void* handle);
97 [DllImport(PHYSFS_DLLNAME)] public static extern unsafe long PHYSFS_getLastModTime(string filename);
98 [DllImport(PHYSFS_DLLNAME)] public static extern unsafe long PHYSFS_read(void* handle,
102 [DllImport(PHYSFS_DLLNAME)] public static extern unsafe long PHYSFS_write(void* handle,
106 [DllImport(PHYSFS_DLLNAME)] public static extern unsafe int PHYSFS_eof(void* handle);
107 [DllImport(PHYSFS_DLLNAME)] public static extern unsafe long PHYSFS_tell(void* handle);
108 [DllImport(PHYSFS_DLLNAME)] public static extern unsafe int PHYSFS_seek(void* handle, ulong pos);
109 [DllImport(PHYSFS_DLLNAME)] public static extern unsafe long PHYSFS_fileLength(void* handle);
110 [DllImport(PHYSFS_DLLNAME)] public static extern unsafe int PHYSFS_setBuffer(void* handle, ulong bufsize);
111 [DllImport(PHYSFS_DLLNAME)] public static extern unsafe int PHYSFS_flush(void* handle);