Fixed string marshalling

pull/2/head
Francesco Bertolaccini 2016-01-28 22:04:55 +01:00
parent 974feee6a8
commit 2da0bb9d5d
2 changed files with 12 additions and 16 deletions

View File

@ -106,8 +106,6 @@ namespace PhysFS
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate IntPtr FnGetLastError();
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate string FnGetDirSeparator();
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void FnPermitSymbolicLinks(int permit);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate int FnSetWriteDir(string s);
@ -116,8 +114,6 @@ namespace PhysFS
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate int FnSetSaneConfig(string s1, string s2, string s3, int i1, int i2);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate string FnGetRealDir(string s);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate IntPtr FnEnumerateFiles(string s);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate long FnGetLastModTime(string s);
@ -144,12 +140,12 @@ namespace PhysFS
public static FnSupportedArchiveTypes PHYSFS_supportedArchiveTypes;
public static FnFreeList PHYSFS_freeList;
public static FnGetLastError PHYSFS_getLastError;
public static FnGetDirSeparator PHYSFS_getDirSeparator;
public static FnGetLastError PHYSFS_getDirSeparator;
public static FnPermitSymbolicLinks PHYSFS_permitSymbolicLinks;
public static FnSupportedArchiveTypes PHYSFS_getCdRomDirs;
public static FnGetDirSeparator PHYSFS_getBaseDir;
public static FnGetDirSeparator PHYSFS_getUserDir;
public static FnGetDirSeparator PHYSFS_getWriteDir;
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;
@ -157,7 +153,7 @@ namespace PhysFS
public static FnSetSaneConfig PHYSFS_setSaneConfig;
public static FnSetWriteDir PHYSFS_mkdir;
public static FnSetWriteDir PHYSFS_delete;
public static FnGetRealDir PHYSFS_getRealDir;
public static FnEnumerateFiles PHYSFS_getRealDir;
public static FnEnumerateFiles PHYSFS_enumerateFiles;
public static FnSetWriteDir PHYSFS_exists;
public static FnSetWriteDir PHYSFS_isDirectory;
@ -179,7 +175,7 @@ namespace PhysFS
public static FnDeinit PHYSFS_symbolicLinksPermitted;
public static FnSetAllocator PHYSFS_setAllocator;
public static FnMount PHYSFS_mount;
public static FnGetRealDir PHYSFS_getMountPoint;
public static FnEnumerateFiles PHYSFS_getMountPoint;
public static FnGetCdRomDirsCallback PHYSFS_getCdRomDirsCallback;
public static FnGetCdRomDirsCallback PHYSFS_getSearchPathCallback;
public static FnEnumerateFilesCallback PHYSFS_enumerateFilesCallback;

View File

@ -243,7 +243,7 @@ namespace PhysFS
/// <returns>Platform-dependent dir separator string</returns>
public static string GetDirSeparator()
{
return Interop.PHYSFS_getDirSeparator();
return Marshal.PtrToStringAnsi(Interop.PHYSFS_getDirSeparator());
}
/// <summary>
@ -367,7 +367,7 @@ namespace PhysFS
/// <returns></returns>
public static string GetBaseDir()
{
return Interop.PHYSFS_getBaseDir();
return Marshal.PtrToStringAnsi(Interop.PHYSFS_getBaseDir());
}
/// <summary>
@ -385,7 +385,7 @@ namespace PhysFS
/// <returns>String of user dir in platform-dependent notation.</returns>
public static string GetUserDir()
{
return Interop.PHYSFS_getUserDir();
return Marshal.PtrToStringAnsi(Interop.PHYSFS_getUserDir());
}
/// <summary>
@ -397,7 +397,7 @@ namespace PhysFS
/// <returns>String of write dir in platform-dependent notation, OR null IF NO WRITE PATH IS CURRENTLY SET</returns>
public static string GetWriteDir()
{
return Interop.PHYSFS_getWriteDir();
return Marshal.PtrToStringAnsi(Interop.PHYSFS_getWriteDir());
}
/// <summary>
@ -589,7 +589,7 @@ namespace PhysFS
/// <returns>String of element of search path containing the the file in question. null if not found.</returns>
public static string GetRealDir(string filename)
{
return Interop.PHYSFS_getRealDir(filename);
return Marshal.PtrToStringAnsi(Interop.PHYSFS_getRealDir(filename));
}
/// <summary>
@ -692,7 +692,7 @@ namespace PhysFS
/// <returns>String of mount point if added to path</returns>
public static string GetMountPoint(string dir)
{
var s = Interop.PHYSFS_getMountPoint(dir);
var s = Marshal.PtrToStringAnsi(Interop.PHYSFS_getMountPoint(dir));
if(s == null)
{
throw new PhysFSException();