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

os: make chmod() return error

This commit is contained in:
Alexander Medvednikov 2021-08-28 09:37:24 +03:00
parent 858ba25d55
commit 853d3cb83e
5 changed files with 6 additions and 6 deletions

View File

@ -101,7 +101,7 @@ pub fn listen_stream(sock string) ?&StreamListener {
os.rm(sock) ?
}
net.socket_error(C.bind(s.handle, voidptr(&addr), size)) ?
os.chmod(sock, 0o777)
os.chmod(sock, 0o777) ?
net.socket_error(C.listen(s.handle, 128)) ?
return &StreamListener{
sock: s

View File

@ -886,9 +886,9 @@ pub fn flush() {
// chmod change file access attributes of `path` to `mode`.
// Octals like `0o600` can be used.
pub fn chmod(path string, mode int) {
pub fn chmod(path string, mode int)? {
if C.chmod(&char(path.str), mode) != 0 {
panic('chmod failed: ' + posix_get_error_msg(C.errno))
return error_with_code('chmod failed: ' + posix_get_error_msg(C.errno), C.errno)
}
}

View File

@ -748,7 +748,7 @@ fn (mut b Builder) ensure_linuxroot_exists(sysroot string) {
if !os.exists(sysroot_git_config_path) {
verror('Failed to clone `$crossrepo_url` to `$sysroot`')
}
os.chmod(os.join_path(sysroot, 'ld.lld'), 0o755)
os.chmod(os.join_path(sysroot, 'ld.lld'), 0o755) or { panic(err) }
}
}

View File

@ -117,7 +117,7 @@ pub fn (mut g Gen) generate_header() {
pub fn (mut g Gen) create_executable() {
// Create the binary // should be .o ?
os.write_file_array(g.out_name, g.buf) or { panic(err) }
os.chmod(g.out_name, 0o775) // make it executable
os.chmod(g.out_name, 0o775) or { panic(err) } // make it executable
if g.pref.is_verbose {
println('\n$g.out_name: native binary has been successfully generated')
}

View File

@ -77,7 +77,7 @@ pub fn (mut cm CacheManager) key2cpath(key string) string {
cpath = os.join_path(cprefix_folder, khash)
if !os.is_dir(cprefix_folder) {
os.mkdir_all(cprefix_folder) or { panic(err) }
os.chmod(cprefix_folder, 0o777)
os.chmod(cprefix_folder, 0o777) or { panic(err) }
}
dlog(@FN, 'new hk')
dlog(@FN, ' key: $key')