Initialize callbacks with better error messages

pull/2/head
Francesco Bertolaccini 2016-01-31 21:23:40 +01:00
parent c2b56cf342
commit 10f87aa9ce
1 changed files with 48 additions and 45 deletions

View File

@ -145,51 +145,54 @@ namespace SharpPhysFS
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void FnEnumerateFilesCallback(string s, EnumFilesCallback c, IntPtr ptr);
public static FnGetLinkedVersion PHYSFS_getLinkedVersion;
public static FnInit PHYSFS_init;
public static FnDeinit PHYSFS_deinit;
public static FnSupportedArchiveTypes PHYSFS_supportedArchiveTypes;
public static FnFreeList PHYSFS_freeList;
public static FnGetLastError PHYSFS_getLastError;
public static FnGetLastError PHYSFS_getDirSeparator;
public static FnPermitSymbolicLinks PHYSFS_permitSymbolicLinks;
public static FnSupportedArchiveTypes PHYSFS_getCdRomDirs;
public static FnGetLastError PHYSFS_getBaseDir;
public static FnGetLastError PHYSFS_getUserDir;
public static FnGetLastError PHYSFS_getWriteDir;
public static FnSetWriteDir PHYSFS_setWriteDir;
public static FnAddToSearchPath PHYSFS_addToSearchPath;
public static FnSetWriteDir PHYSFS_removeFromSearchPath;
public static FnSupportedArchiveTypes PHYSFS_getSearchPath;
public static FnSetSaneConfig PHYSFS_setSaneConfig;
public static FnSetWriteDir PHYSFS_mkdir;
public static FnSetWriteDir PHYSFS_delete;
public static FnEnumerateFiles PHYSFS_getRealDir;
public static FnEnumerateFiles PHYSFS_enumerateFiles;
public static FnSetWriteDir PHYSFS_exists;
public static FnSetWriteDir PHYSFS_isDirectory;
public static FnSetWriteDir PHYSFS_isSymbolicLink;
public static FnGetLastModTime PHYSFS_getLastModTime;
public static FnEnumerateFiles PHYSFS_openWrite;
public static FnEnumerateFiles PHYSFS_openAppend;
public static FnEnumerateFiles PHYSFS_openRead;
public static FnClose PHYSFS_close;
public static FnRead PHYSFS_read;
public static FnRead PHYSFS_write;
public static FnClose PHYSFS_eof;
public static FnTell PHYSFS_tell;
public static FnSeek PHYSFS_seek;
public static FnFileLength PHYSFS_fileLength;
public static FnSeek PHYSFS_setBuffer;
public static FnClose PHYSFS_flush;
public static FnDeinit PHYSFS_isInit;
public static FnDeinit PHYSFS_symbolicLinksPermitted;
public static FnSetAllocator PHYSFS_setAllocator;
public static FnMount PHYSFS_mount;
public static FnEnumerateFiles PHYSFS_getMountPoint;
public static FnGetCdRomDirsCallback PHYSFS_getCdRomDirsCallback;
public static FnGetCdRomDirsCallback PHYSFS_getSearchPathCallback;
public static FnEnumerateFilesCallback PHYSFS_enumerateFilesCallback;
// When the callbacks are not yet initialized, instead of throwing a
// null reference exception we explain the problem.
// I think it makes for a more graceful failure.
public static FnGetLinkedVersion PHYSFS_getLinkedVersion = (ref Version v) => { throw new InvalidOperationException("Callbacks not initialized yet"); };
public static FnInit PHYSFS_init = (a) => { throw new InvalidOperationException("Callbacks not initialized yet"); };
public static FnDeinit PHYSFS_deinit = () => { throw new InvalidOperationException("Callbacks not initialized yet"); };
public static FnSupportedArchiveTypes PHYSFS_supportedArchiveTypes = () => { throw new InvalidOperationException("Callbacks not initialized yet"); };
public static FnFreeList PHYSFS_freeList = (a) => { throw new InvalidOperationException("Callbacks not initialized yet"); };
public static FnGetLastError PHYSFS_getLastError = () => { throw new InvalidOperationException("Callbacks not initialized yet"); };
public static FnGetLastError PHYSFS_getDirSeparator = () => { throw new InvalidOperationException("Callbacks not initialized yet"); };
public static FnPermitSymbolicLinks PHYSFS_permitSymbolicLinks = (a) => { throw new InvalidOperationException("Callbacks not initialized yet"); };
public static FnSupportedArchiveTypes PHYSFS_getCdRomDirs = () => { throw new InvalidOperationException("Callbacks not initialized yet"); };
public static FnGetLastError PHYSFS_getBaseDir = () => { throw new InvalidOperationException("Callbacks not initialized yet"); };
public static FnGetLastError PHYSFS_getUserDir = () => { throw new InvalidOperationException("Callbacks not initialized yet"); };
public static FnGetLastError PHYSFS_getWriteDir = () => { throw new InvalidOperationException("Callbacks not initialized yet"); };
public static FnSetWriteDir PHYSFS_setWriteDir = (a) => { throw new InvalidOperationException("Callbacks not initialized yet"); };
public static FnAddToSearchPath PHYSFS_addToSearchPath = (a, b) => { throw new InvalidOperationException("Callbacks not initialized yet"); };
public static FnSetWriteDir PHYSFS_removeFromSearchPath = (a) => { throw new InvalidOperationException("Callbacks not initialized yet"); };
public static FnSupportedArchiveTypes PHYSFS_getSearchPath = () => { throw new InvalidOperationException("Callbacks not initialized yet"); };
public static FnSetSaneConfig PHYSFS_setSaneConfig = (a, b, c, d, e) => { throw new InvalidOperationException("Callbacks not initialized yet"); };
public static FnSetWriteDir PHYSFS_mkdir = (a) => { throw new InvalidOperationException("Callbacks not initialized yet"); };
public static FnSetWriteDir PHYSFS_delete = (a) => { throw new InvalidOperationException("Callbacks not initialized yet"); };
public static FnEnumerateFiles PHYSFS_getRealDir = (a) => { throw new InvalidOperationException("Callbacks not initialized yet"); };
public static FnEnumerateFiles PHYSFS_enumerateFiles = (a) => { throw new InvalidOperationException("Callbacks not initialized yet"); };
public static FnSetWriteDir PHYSFS_exists = (a) => { throw new InvalidOperationException("Callbacks not initialized yet"); };
public static FnSetWriteDir PHYSFS_isDirectory = (a) => { throw new InvalidOperationException("Callbacks not initialized yet"); };
public static FnSetWriteDir PHYSFS_isSymbolicLink = (a) => { throw new InvalidOperationException("Callbacks not initialized yet"); };
public static FnGetLastModTime PHYSFS_getLastModTime = (a) => { throw new InvalidOperationException("Callbacks not initialized yet"); };
public static FnEnumerateFiles PHYSFS_openWrite = (a) => { throw new InvalidOperationException("Callbacks not initialized yet"); };
public static FnEnumerateFiles PHYSFS_openAppend = (a) => { throw new InvalidOperationException("Callbacks not initialized yet"); };
public static FnEnumerateFiles PHYSFS_openRead = (a) => { throw new InvalidOperationException("Callbacks not initialized yet"); };
public static FnClose PHYSFS_close = (a) => { throw new InvalidOperationException("Callbacks not initialized yet"); };
public static FnRead PHYSFS_read = (a, b, c, d) => { throw new InvalidOperationException("Callbacks not initialized yet"); };
public static FnRead PHYSFS_write = (a, b, c,d ) => { throw new InvalidOperationException("Callbacks not initialized yet"); };
public static FnClose PHYSFS_eof = (a) => { throw new InvalidOperationException("Callbacks not initialized yet"); };
public static FnTell PHYSFS_tell = (a) => { throw new InvalidOperationException("Callbacks not initialized yet"); };
public static FnSeek PHYSFS_seek = (a, b) => { throw new InvalidOperationException("Callbacks not initialized yet"); };
public static FnFileLength PHYSFS_fileLength = (a) => { throw new InvalidOperationException("Callbacks not initialized yet"); };
public static FnSeek PHYSFS_setBuffer = (a, b) => { throw new InvalidOperationException("Callbacks not initialized yet"); };
public static FnClose PHYSFS_flush = (a) => { throw new InvalidOperationException("Callbacks not initialized yet"); };
public static FnDeinit PHYSFS_isInit = () => { throw new InvalidOperationException("Callbacks not initialized yet"); };
public static FnDeinit PHYSFS_symbolicLinksPermitted = () => { throw new InvalidOperationException("Callbacks not initialized yet"); };
public static FnSetAllocator PHYSFS_setAllocator = (a) => { throw new InvalidOperationException("Callbacks not initialized yet"); };
public static FnMount PHYSFS_mount = (a, b, c) => { throw new InvalidOperationException("Callbacks not initialized yet"); };
public static FnEnumerateFiles PHYSFS_getMountPoint = (a) => { throw new InvalidOperationException("Callbacks not initialized yet"); };
public static FnGetCdRomDirsCallback PHYSFS_getCdRomDirsCallback = (a, b) => { throw new InvalidOperationException("Callbacks not initialized yet"); };
public static FnGetCdRomDirsCallback PHYSFS_getSearchPathCallback = (a, b) => { throw new InvalidOperationException("Callbacks not initialized yet"); };
public static FnEnumerateFilesCallback PHYSFS_enumerateFilesCallback = (a, b, c) => { throw new InvalidOperationException("Callbacks not initialized yet"); };
public static void SetUpInterop()
{