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',
|
'cmd/v/v.v',
|
||||||
'vlib/builtin/array.v',
|
'vlib/builtin/array.v',
|
||||||
'vlib/builtin/map.v',
|
'vlib/builtin/map.v',
|
||||||
'vlib/os/file.c.v',
|
|
||||||
'vlib/math/bits/bits.v',
|
'vlib/math/bits/bits.v',
|
||||||
'vlib/time/time.v',
|
'vlib/time/time.v',
|
||||||
'vlib/term/colors.v',
|
'vlib/term/colors.v',
|
||||||
|
@ -58,19 +57,8 @@ const (
|
||||||
'vlib/v/vet/',
|
'vlib/v/vet/',
|
||||||
'vlib/v/vmod/',
|
'vlib/v/vmod/',
|
||||||
'vlib/gg/gg.v',
|
'vlib/gg/gg.v',
|
||||||
'vlib/os/const.v',
|
'vlib/os/',
|
||||||
'vlib/os/const_windows.c.v',
|
'vlib/time/',
|
||||||
'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',
|
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -26,8 +26,7 @@ pub fn option(args []string, param string, def string) string {
|
||||||
for arg in args {
|
for arg in args {
|
||||||
if found {
|
if found {
|
||||||
return arg
|
return arg
|
||||||
}
|
} else if param == arg {
|
||||||
else if param == arg {
|
|
||||||
found = true
|
found = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,15 +2,15 @@ module os
|
||||||
|
|
||||||
// File modes
|
// File modes
|
||||||
const (
|
const (
|
||||||
o_rdonly = 000000000 // open the file read-only.
|
o_rdonly = 0o00000000 // open the file read-only.
|
||||||
o_wronly = 000000001 // open the file write-only.
|
o_wronly = 0o00000001 // open the file write-only.
|
||||||
o_rdwr = 000000002 // open the file read-write.
|
o_rdwr = 0o00000002 // open the file read-write.
|
||||||
o_create = 000000100 // create a new file if none exists.
|
o_binary = 0o00000000 // input and output is not translated; the default on unix
|
||||||
o_binary = 000008000 // input and output is not translated.
|
o_create = 0o00000100 // create a new file if none exists.
|
||||||
o_excl = 000000200 // used with o_create, file must not exist.
|
o_excl = 0o00000200 // used with o_create, file must not exist.
|
||||||
o_noctty = 000000400 // if file is terminal, don't make it the controller terminal
|
o_noctty = 0o00000400 // if file is terminal, don't make it the controller terminal
|
||||||
o_trunc = 000001000 // truncate regular writable file when opened.
|
o_trunc = 0o00001000 // truncate regular writable file when opened.
|
||||||
o_append = 000002000 // append data to the file when writing.
|
o_append = 0o00002000 // append data to the file when writing.
|
||||||
o_nonblock = 000004000 // prevents blocking when opening files
|
o_nonblock = 0o00004000 // prevents blocking when opening files
|
||||||
o_sync = 000010000 // open for synchronous I/O.
|
o_sync = 0o04010000 // open for synchronous I/O.
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,14 +1,21 @@
|
||||||
module os
|
module os
|
||||||
|
|
||||||
struct C.ANativeActivity {
|
struct C.AAset {
|
||||||
assetManager &C.AAsetManager
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct C.AAset {}
|
struct C.AAssetManager {
|
||||||
|
}
|
||||||
|
|
||||||
|
struct C.ANativeActivity {
|
||||||
|
assetManager voidptr
|
||||||
|
}
|
||||||
|
|
||||||
fn C.AAssetManager_open(&C.AAsetManager, charptr, int) &C.AAset
|
fn C.AAssetManager_open(&C.AAsetManager, charptr, int) &C.AAset
|
||||||
|
|
||||||
fn C.AAsset_getLength(&C.AAset) int
|
fn C.AAsset_getLength(&C.AAset) int
|
||||||
|
|
||||||
fn C.AAsset_read(&C.AAset, voidptr, int) int
|
fn C.AAsset_read(&C.AAset, voidptr, int) int
|
||||||
|
|
||||||
fn C.AAsset_close(&C.AAsset)
|
fn C.AAsset_close(&C.AAsset)
|
||||||
|
|
||||||
pub fn read_apk_asset(file string) ?[]byte {
|
pub fn read_apk_asset(file string) ?[]byte {
|
||||||
|
@ -16,14 +23,16 @@ pub fn read_apk_asset(file string) ?[]byte {
|
||||||
if isnil(act) {
|
if isnil(act) {
|
||||||
return error('Could not get reference to Android activity')
|
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) {
|
if isnil(asset) {
|
||||||
return error('File `$file` not found')
|
return error('File `$file` not found')
|
||||||
}
|
}
|
||||||
len := C.AAsset_getLength(asset)
|
len := C.AAsset_getLength(asset)
|
||||||
buf := []byte{len: len}
|
buf := []byte{len: len}
|
||||||
for {
|
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)
|
C.AAsset_close(asset)
|
||||||
return buf
|
return buf
|
||||||
|
|
Loading…
Reference in New Issue