Skip to content

Commit

Permalink
Make GetFullPathName function use more succinct
Browse files Browse the repository at this point in the history
The function will always be there on Windows.
And if it's not, we'll now fail with NPE instead of RuntimeException.
Either way it's a crash. *shrug*
  • Loading branch information
ctrueden committed May 4, 2024
1 parent 5d3c154 commit 1e40ddd
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/windowsMain/kotlin/file.kt
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,7 @@ private fun canonicalize(path: String): String {
val bufferLength = MAX_PATH
memScoped {
val buffer = allocArray<UShortVar>(bufferLength)
val fullPathLength = GetFullPathName?.let { it(p.wcstr.ptr, bufferLength.toUInt(), buffer, null) } ?:
throw RuntimeException("GetFullPathName function not available")
val fullPathLength = GetFullPathName!!(p.wcstr.ptr, bufferLength.toUInt(), buffer, null)
if (fullPathLength == 0u) throw RuntimeException("Failed to get full path: ${GetLastError()}")
return buffer.toKString()
}
Expand Down

0 comments on commit 1e40ddd

Please sign in to comment.