Can someone help me with this function? I want to ...
# kotlin-native
g
Can someone help me with this function? I want to implement
<http://java.io|java.io>.File#path
using Windows native apis. However, I'm not sure which arguments I should supply this function with and how to convert resulting
DWORD
to Kotlin's
String
g
maybe toKString()? Though, I’m not familiar with WinAPI, toKString() used for standard C strings (arrays)
g
This function returns
UInt
, so I guess the result of this function should be put into a buffer, that you pass as an argument. However, I have no idea how to create this buffer and then read value from it
g
ah I see, you need something like this:
Copy code
val length = 4096
val buffer = allocArray<ByteVar>(length)

GetFullPathNameW(pathname, length, buffer null)
This will allocate simple bytevar array Another way is to use Kotlin buffer, something like this:
Copy code
val buffer = ByteArray(4096)
GetFullPathNameW(pathname, buffer.size, buffer.refTo(0).getPointer(this /* memScoped */), null)