os: use `return none` in functions returning `?`

pull/5516/head^2
Delyan Angelov 2020-06-26 17:56:34 +03:00
parent 2440ffd013
commit c83c5e7c61
1 changed files with 15 additions and 13 deletions

View File

@ -196,7 +196,7 @@ pub fn cp(old, new string) ? {
return error_with_code('failed to set permissions for $new', int(-1))
}
}
return
return none
}
[deprecated]
@ -225,7 +225,7 @@ pub fn cp_all(osource_path, odest_path string, overwrite bool) ? {
os.cp(source_path, adjusted_path) or {
return error(err)
}
return
return none
}
if !os.is_dir(dest_path) {
return error('Destination path is not a valid directory')
@ -246,7 +246,7 @@ pub fn cp_all(osource_path, odest_path string, overwrite bool) ? {
panic(err)
}
}
return
return none
}
// mv_by_cp first copies the source file, and if it is copied successfully, deletes the source file.
@ -258,7 +258,7 @@ pub fn mv_by_cp(source string, target string) ? {
os.rm(source) or {
return error(err)
}
return
return none
}
// vfopen returns an opened C file, given its path and open mode.
@ -638,23 +638,24 @@ pub fn rm(path string) ? {
return error(posix_get_error_msg(C.errno))
}
}
return
return none
// C.unlink(path.cstr())
}
// rmdir removes a specified directory.
pub fn rmdir(path string) ? {
$if !windows {
$if windows {
rc := C.RemoveDirectory(path.to_wide())
if rc == 0 {
// https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-removedirectorya - 0 is failure
return error('Failed to remove "$path"')
}
} $else {
rc := C.rmdir(path.str)
if rc == -1 {
return error(posix_get_error_msg(C.errno))
}
} $else {
rc := C.RemoveDirectory(path.to_wide())
if rc == 0 {
return error('Failed to remove "$path"')
}
}
return none
}
[deprecated]
@ -666,7 +667,7 @@ pub fn rmdir_recursive(path string) {
pub fn rmdir_all(path string) ? {
mut ret_err := ''
items := os.ls(path) or {
return
return none
}
for item in items {
if os.is_dir(os.join_path(path, item)) {
@ -678,6 +679,7 @@ pub fn rmdir_all(path string) ? {
if ret_err.len > 0 {
return error(ret_err)
}
return none
}
pub fn is_dir_empty(path string) bool {