NormFile Refactor
* Updated NormFileGetName to use sbyte* to avoid casting * Updated designpull/85/head
parent
e4513ccd53
commit
3ee6345fd0
|
|
@ -97,7 +97,7 @@ class NormApi <<static>> {
|
||||||
+ {static} <<extern>> NormObjectCancel(objectHandle:long) : void
|
+ {static} <<extern>> NormObjectCancel(objectHandle:long) : void
|
||||||
+ {static} <<extern>> NormObjectRetain(objectHandle:long) : void
|
+ {static} <<extern>> NormObjectRetain(objectHandle:long) : void
|
||||||
+ {static} <<extern>> NormObjectRelease(objectHandle:long) : void
|
+ {static} <<extern>> NormObjectRelease(objectHandle:long) : void
|
||||||
+ {static} <<extern>> NormFileGetName(fileHandle:long, nameBuffer:nint, bufferLen:int) : bool
|
+ <<unsafe>> {static} <<extern>> NormFileGetName(fileHandle:long, nameBuffer:sbyte*, bufferLen:int) : bool
|
||||||
+ {static} <<extern>> NormFileRename(fileHandle:long, fileName:string) : bool
|
+ {static} <<extern>> NormFileRename(fileHandle:long, fileName:string) : bool
|
||||||
+ {static} <<extern>> NormDataAccessData(objectHandle:long) : nint
|
+ {static} <<extern>> NormDataAccessData(objectHandle:long) : nint
|
||||||
+ {static} <<extern>> NormObjectGetSender(objectHandle:long) : long
|
+ {static} <<extern>> NormObjectGetSender(objectHandle:long) : long
|
||||||
|
|
|
||||||
|
|
@ -1020,7 +1020,7 @@ namespace Mil.Navy.Nrl.Norm
|
||||||
/// does not refer to an object of type NORM_OBJECT_FILE.
|
/// does not refer to an object of type NORM_OBJECT_FILE.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[DllImport(NORM_LIBRARY)]
|
[DllImport(NORM_LIBRARY)]
|
||||||
public static extern bool NormFileGetName(long fileHandle, nint nameBuffer, int bufferLen);
|
public unsafe static extern bool NormFileGetName(long fileHandle, sbyte* nameBuffer, int bufferLen);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This function renames the file used to store content for the NORM_OBJECT_FILE transport object specified by
|
/// This function renames the file used to store content for the NORM_OBJECT_FILE transport object specified by
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,4 @@
|
||||||
using System.Runtime.InteropServices;
|
namespace Mil.Navy.Nrl.Norm
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace Mil.Navy.Nrl.Norm
|
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A transport object of type NORM_OBJECT_FILE.
|
/// A transport object of type NORM_OBJECT_FILE.
|
||||||
|
|
@ -29,16 +26,14 @@ namespace Mil.Navy.Nrl.Norm
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
var buffer = stackalloc byte[FILENAME_MAX];
|
var buffer = stackalloc sbyte[FILENAME_MAX];
|
||||||
var bufferPtr = (nint)buffer;
|
|
||||||
|
|
||||||
if (!NormFileGetName(_handle, bufferPtr, FILENAME_MAX))
|
if (!NormFileGetName(_handle, buffer, FILENAME_MAX))
|
||||||
{
|
{
|
||||||
throw new IOException("Failed to get file name");
|
throw new IOException("Failed to get file name");
|
||||||
}
|
}
|
||||||
var name = Marshal.PtrToStringAnsi(bufferPtr);
|
|
||||||
|
return new string(buffer);
|
||||||
return name ?? string.Empty;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue