darwin: fix the C. function declarations (#9194)
parent
b64d781a20
commit
4d24cb0158
|
@ -30,22 +30,22 @@ pub fn nsstring(s string) voidptr {
|
|||
// for .app packages: .../my.app/Contents/Resources
|
||||
// for cli: .../parent_folder/Resources
|
||||
|
||||
fn C.CFBundleCopyResourcesDirectoryURL() byteptr
|
||||
fn C.CFBundleCopyResourcesDirectoryURL(bundle voidptr) byteptr
|
||||
fn C.CFBundleGetMainBundle() voidptr
|
||||
fn C.CFURLGetFileSystemRepresentation() int
|
||||
fn C.CFRelease()
|
||||
fn C.CFURLGetFileSystemRepresentation(url byteptr, resolve_against_base bool, buffer byteptr, buffer_size int) int
|
||||
fn C.CFRelease(url byteptr)
|
||||
|
||||
pub fn resource_path() string {
|
||||
|
||||
main_bundle := C.CFBundleGetMainBundle()
|
||||
resource_dir_url := C.CFBundleCopyResourcesDirectoryURL(main_bundle)
|
||||
if isnil(resource_dir_url) {
|
||||
panic('CFBundleCopyResourcesDirectoryURL failed')
|
||||
}
|
||||
buffer_size := 4096
|
||||
mut buffer := malloc(buffer_size)
|
||||
buffer[0] = 0
|
||||
conv_result := C.CFURLGetFileSystemRepresentation(resource_dir_url, true, buffer, buffer_size)
|
||||
mut buffer := unsafe{ malloc(buffer_size) }
|
||||
unsafe{ buffer[0] = 0 }
|
||||
conv_result := C.CFURLGetFileSystemRepresentation(resource_dir_url, true, buffer,
|
||||
buffer_size)
|
||||
if conv_result == 0 {
|
||||
panic('CFURLGetFileSystemRepresentation failed')
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue