mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
os: vfmt all of os
.v files, add it to v test-cleancode
with no exceptions
This commit is contained in:
@ -1,14 +1,21 @@
|
||||
module os
|
||||
|
||||
struct C.ANativeActivity {
|
||||
assetManager &C.AAsetManager
|
||||
struct C.AAset {
|
||||
}
|
||||
|
||||
struct C.AAset {}
|
||||
struct C.AAssetManager {
|
||||
}
|
||||
|
||||
struct C.ANativeActivity {
|
||||
assetManager voidptr
|
||||
}
|
||||
|
||||
fn C.AAssetManager_open(&C.AAsetManager, charptr, int) &C.AAset
|
||||
|
||||
fn C.AAsset_getLength(&C.AAset) int
|
||||
|
||||
fn C.AAsset_read(&C.AAset, voidptr, int) int
|
||||
|
||||
fn C.AAsset_close(&C.AAsset)
|
||||
|
||||
pub fn read_apk_asset(file string) ?[]byte {
|
||||
@ -16,14 +23,16 @@ pub fn read_apk_asset(file string) ?[]byte {
|
||||
if isnil(act) {
|
||||
return error('Could not get reference to Android activity')
|
||||
}
|
||||
asset := C.AAssetManager_open(act.assetManager, file.str, C.AASSET_MODE_STREAMING)
|
||||
asset := C.AAssetManager_open(&C.AAsetManager(act.assetManager), file.str, C.AASSET_MODE_STREAMING)
|
||||
if isnil(asset) {
|
||||
return error('File `$file` not found')
|
||||
}
|
||||
len := C.AAsset_getLength(asset)
|
||||
buf := []byte{ len: len }
|
||||
buf := []byte{len: len}
|
||||
for {
|
||||
if C.AAsset_read(asset, buf.data, len) > 0 { break }
|
||||
if C.AAsset_read(asset, buf.data, len) > 0 {
|
||||
break
|
||||
}
|
||||
}
|
||||
C.AAsset_close(asset)
|
||||
return buf
|
||||
|
Reference in New Issue
Block a user