os: vfmt all of `os` .v files, add it to `v test-cleancode` with no exceptions
parent
6a74058190
commit
1ee57649b9
|
@ -22,7 +22,6 @@ const (
|
|||
'cmd/v/v.v',
|
||||
'vlib/builtin/array.v',
|
||||
'vlib/builtin/map.v',
|
||||
'vlib/os/file.c.v',
|
||||
'vlib/math/bits/bits.v',
|
||||
'vlib/time/time.v',
|
||||
'vlib/term/colors.v',
|
||||
|
@ -58,19 +57,8 @@ const (
|
|||
'vlib/v/vet/',
|
||||
'vlib/v/vmod/',
|
||||
'vlib/gg/gg.v',
|
||||
'vlib/os/const.v',
|
||||
'vlib/os/const_windows.c.v',
|
||||
'vlib/os/environment.c.v',
|
||||
'vlib/os/environment_test.v',
|
||||
'vlib/os/inode.c.v',
|
||||
'vlib/os/inode_test.v',
|
||||
'vlib/os/os.v',
|
||||
'vlib/os/os_c.v',
|
||||
'vlib/os/os_darwin.c.v',
|
||||
'vlib/os/os_linux.c.v',
|
||||
'vlib/os/os_nix.c.v',
|
||||
'vlib/os/os_test.v',
|
||||
'vlib/os/os_windows.c.v',
|
||||
'vlib/os/',
|
||||
'vlib/time/',
|
||||
]
|
||||
)
|
||||
|
||||
|
|
|
@ -26,8 +26,7 @@ pub fn option(args []string, param string, def string) string {
|
|||
for arg in args {
|
||||
if found {
|
||||
return arg
|
||||
}
|
||||
else if param == arg {
|
||||
} else if param == arg {
|
||||
found = true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,15 +2,15 @@ module os
|
|||
|
||||
// File modes
|
||||
const (
|
||||
o_rdonly = 000000000 // open the file read-only.
|
||||
o_wronly = 000000001 // open the file write-only.
|
||||
o_rdwr = 000000002 // open the file read-write.
|
||||
o_create = 000000100 // create a new file if none exists.
|
||||
o_binary = 000008000 // input and output is not translated.
|
||||
o_excl = 000000200 // used with o_create, file must not exist.
|
||||
o_noctty = 000000400 // if file is terminal, don't make it the controller terminal
|
||||
o_trunc = 000001000 // truncate regular writable file when opened.
|
||||
o_append = 000002000 // append data to the file when writing.
|
||||
o_nonblock = 000004000 // prevents blocking when opening files
|
||||
o_sync = 000010000 // open for synchronous I/O.
|
||||
o_rdonly = 0o00000000 // open the file read-only.
|
||||
o_wronly = 0o00000001 // open the file write-only.
|
||||
o_rdwr = 0o00000002 // open the file read-write.
|
||||
o_binary = 0o00000000 // input and output is not translated; the default on unix
|
||||
o_create = 0o00000100 // create a new file if none exists.
|
||||
o_excl = 0o00000200 // used with o_create, file must not exist.
|
||||
o_noctty = 0o00000400 // if file is terminal, don't make it the controller terminal
|
||||
o_trunc = 0o00001000 // truncate regular writable file when opened.
|
||||
o_append = 0o00002000 // append data to the file when writing.
|
||||
o_nonblock = 0o00004000 // prevents blocking when opening files
|
||||
o_sync = 0o04010000 // open for synchronous I/O.
|
||||
)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue