diff --git a/vlib/net/unix/stream_nix.v b/vlib/net/unix/stream_nix.v index 450f1fe46e..e73acb7b8a 100644 --- a/vlib/net/unix/stream_nix.v +++ b/vlib/net/unix/stream_nix.v @@ -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 diff --git a/vlib/os/os.c.v b/vlib/os/os.c.v index 4416543016..e6024a13d9 100644 --- a/vlib/os/os.c.v +++ b/vlib/os/os.c.v @@ -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) } } diff --git a/vlib/v/builder/cc.v b/vlib/v/builder/cc.v index 214f73bce9..de05059f07 100644 --- a/vlib/v/builder/cc.v +++ b/vlib/v/builder/cc.v @@ -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) } } } diff --git a/vlib/v/gen/native/gen.v b/vlib/v/gen/native/gen.v index c8bb5c3c48..f24a92c9f1 100644 --- a/vlib/v/gen/native/gen.v +++ b/vlib/v/gen/native/gen.v @@ -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') } diff --git a/vlib/v/vcache/vcache.v b/vlib/v/vcache/vcache.v index cb26db8289..02faf833b1 100644 --- a/vlib/v/vcache/vcache.v +++ b/vlib/v/vcache/vcache.v @@ -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')