There is a situation where I am stuck. With the li...
# kotlin-native
n
There is a situation where I am stuck. With the libssh library I am trying to use the sftp_open function ( https://api.libssh.org/master/group__libssh__sftp.html#gaad64845af1100fb9325f20812f38da3b ), however the last function parameter (mode) seems to be expecting an octal literal (not entirely sure) which Kotlin doesn't support. Also the last function parameter involves doing a bit of bit banging (eg
mode & ~umask
). It isn't clear how to do this with Kotlin since it doesn't provide any bit manipulation operators. Below is the binding for the function:
Copy code
@kotlinx.cinterop.internal.CCall public external fun sftp_open(session: libssh.sftp_session? /* = kotlinx.cinterop.CPointer<libssh.sftp_session_struct>? */, @kotlinx.cinterop.internal.CCall.CString file: kotlin.String?, accesstype: <http://kotlin.Int|kotlin.Int>, mode: libssh.mode_t /* = kotlin.UInt */): libssh.sftp_file? /* = kotlinx.cinterop.CPointer<libssh.sftp_file_struct>? */ { /* compiled code */ }
e
Octal literals are syntax only and AFAIK have no representation in C... everything is converted to integers, so they shouldn't be required. About bit manipulations, these are implemented as functions in Kotlin, (e.g.
or
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/or.html).
👍 1
and
~
would be flip