1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

solaris: make 'v test-compiler' pass (stage 2)

This commit is contained in:
Delyan Angelov
2020-03-21 10:48:02 +02:00
committed by GitHub
parent a5c0d89c71
commit ba088056ed
15 changed files with 236 additions and 9 deletions

View File

@@ -6,6 +6,9 @@ const (
S_IFMT = 0xF000 // type of file
S_IFDIR = 0x4000 // directory
S_IFLNK = 0xa000 // link
S_IXUSR = 0o100 // is executable by the owner
S_IXGRP = 0o010 // is executable by group
S_IXOTH = 0o001 // is executable by others
)
const (

View File

@@ -532,9 +532,15 @@ pub fn is_executable(path string) bool {
// 06 Read and write
p := os.real_path( path )
return ( os.exists( p ) && p.ends_with('.exe') )
} $else {
return C.access(path.str, X_OK) != -1
}
$if solaris {
statbuf := C.stat{}
if C.stat(path.str, &statbuf) != 0 {
return false
}
return (int(statbuf.st_mode) & ( S_IXUSR | S_IXGRP | S_IXOTH )) != 0
}
return C.access(path.str, X_OK) != -1
}
// `is_writable` returns `true` if `path` is writable.