os: make `rm` return an optional
parent
7665114ded
commit
30169f86c1
|
@ -291,7 +291,7 @@ fn C._putenv() int
|
||||||
fn C._waccess() int
|
fn C._waccess() int
|
||||||
|
|
||||||
|
|
||||||
fn C._wremove()
|
fn C._wremove() int
|
||||||
|
|
||||||
|
|
||||||
fn C.ReadConsole() voidptr
|
fn C.ReadConsole() voidptr
|
||||||
|
|
15
vlib/os/os.v
15
vlib/os/os.v
|
@ -628,12 +628,21 @@ pub fn file_exists(_path string) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
// rm removes file in `path`.
|
// rm removes file in `path`.
|
||||||
pub fn rm(path string) {
|
pub fn rm(path string) ? {
|
||||||
$if windows {
|
$if windows {
|
||||||
C._wremove(path.to_wide())
|
rc := C._wremove(path.to_wide())
|
||||||
|
if rc == -1 {
|
||||||
|
//TODO: proper error as soon as it's supported on windows
|
||||||
|
return error('Failed to remove "$path"')
|
||||||
|
}
|
||||||
} $else {
|
} $else {
|
||||||
C.remove(path.str)
|
rc := C.remove(path.str)
|
||||||
|
if rc == -1 {
|
||||||
|
return error(posix_get_error_msg(C.errno))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return
|
||||||
// C.unlink(path.cstr())
|
// C.unlink(path.cstr())
|
||||||
}
|
}
|
||||||
// rmdir removes a specified directory.
|
// rmdir removes a specified directory.
|
||||||
|
|
Loading…
Reference in New Issue