mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
os: disable os.glob() on Android for now (fixes termux compilation)
This commit is contained in:
parent
806d6172cb
commit
7b4c342396
@ -89,12 +89,17 @@ fn C.glob(&char, int, voidptr, voidptr) int
|
|||||||
fn C.globfree(voidptr)
|
fn C.globfree(voidptr)
|
||||||
|
|
||||||
pub fn glob(patterns ...string) ?[]string {
|
pub fn glob(patterns ...string) ?[]string {
|
||||||
|
$if android {
|
||||||
|
return error('os.glob() is not supported on android yet')
|
||||||
|
}
|
||||||
mut matches := []string{}
|
mut matches := []string{}
|
||||||
if patterns.len == 0 {
|
if patterns.len == 0 {
|
||||||
return matches
|
return matches
|
||||||
}
|
}
|
||||||
mut globdata := C.glob_t{
|
mut globdata := C.glob_t{
|
||||||
gl_pathv: 0
|
gl_pathv: 0
|
||||||
|
gl_pathc: size_t(0)
|
||||||
|
gl_offs: size_t(0)
|
||||||
}
|
}
|
||||||
mut flags := int(C.GLOB_DOOFFS | C.GLOB_MARK)
|
mut flags := int(C.GLOB_DOOFFS | C.GLOB_MARK)
|
||||||
for i, pattern in patterns {
|
for i, pattern in patterns {
|
||||||
@ -102,17 +107,21 @@ pub fn glob(patterns ...string) ?[]string {
|
|||||||
flags |= C.GLOB_APPEND
|
flags |= C.GLOB_APPEND
|
||||||
}
|
}
|
||||||
unsafe {
|
unsafe {
|
||||||
|
$if !android {
|
||||||
if C.glob(&char(pattern.str), flags, C.NULL, &globdata) != 0 {
|
if C.glob(&char(pattern.str), flags, C.NULL, &globdata) != 0 {
|
||||||
return error_with_code(posix_get_error_msg(C.errno), C.errno)
|
return error_with_code(posix_get_error_msg(C.errno), C.errno)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
for i := 0; i < int(globdata.gl_pathc); i++ {
|
for i := 0; i < int(globdata.gl_pathc); i++ {
|
||||||
unsafe {
|
unsafe {
|
||||||
matches << cstring_to_vstring(globdata.gl_pathv[i])
|
matches << cstring_to_vstring(globdata.gl_pathv[i])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$if !android {
|
||||||
C.globfree(&globdata)
|
C.globfree(&globdata)
|
||||||
|
}
|
||||||
return matches
|
return matches
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user