Skip to content

Commit

Permalink
SystemHelpers: Let dumpToFile() return the file handle used
Browse files Browse the repository at this point in the history
  • Loading branch information
skalarproduktraum committed Apr 18, 2024
1 parent f9ffb80 commit 770a1d1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main/kotlin/graphics/scenery/utils/SystemHelpers.kt
Original file line number Diff line number Diff line change
Expand Up @@ -241,18 +241,21 @@ class SystemHelpers {
*
* @param[buf] The ByteBuffer to dump.
*/
fun dumpToFile(buf: ByteBuffer, filename: String) {
fun dumpToFile(buf: ByteBuffer, filename: String): File? {
try {
val view = buf.duplicate().order(ByteOrder.LITTLE_ENDIAN)
val file = File(filename)
val channel = FileOutputStream(file, false).channel
channel.write(view)
channel.close()

return file
} catch (e: Exception) {
logger.error("Unable to dump byte buffer to $filename")
e.printStackTrace()
}

return null
}

/**
Expand Down

0 comments on commit 770a1d1

Please sign in to comment.