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>> NormObjectRetain(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>> NormDataAccessData(objectHandle:long) : nint
|
||||
+ {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.
|
||||
/// </returns>
|
||||
[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>
|
||||
/// 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;
|
||||
using System.Text;
|
||||
|
||||
namespace Mil.Navy.Nrl.Norm
|
||||
namespace Mil.Navy.Nrl.Norm
|
||||
{
|
||||
/// <summary>
|
||||
/// A transport object of type NORM_OBJECT_FILE.
|
||||
|
|
@ -29,16 +26,14 @@ namespace Mil.Navy.Nrl.Norm
|
|||
{
|
||||
get
|
||||
{
|
||||
var buffer = stackalloc byte[FILENAME_MAX];
|
||||
var bufferPtr = (nint)buffer;
|
||||
var buffer = stackalloc sbyte[FILENAME_MAX];
|
||||
|
||||
if (!NormFileGetName(_handle, bufferPtr, FILENAME_MAX))
|
||||
if (!NormFileGetName(_handle, buffer, FILENAME_MAX))
|
||||
{
|
||||
throw new IOException("Failed to get file name");
|
||||
}
|
||||
var name = Marshal.PtrToStringAnsi(bufferPtr);
|
||||
|
||||
return name ?? string.Empty;
|
||||
return new string(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue