mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
os: improve rm
error message (#8719)
This commit is contained in:
parent
0b60510c9c
commit
d03c1d615a
@ -432,17 +432,14 @@ pub fn is_readable(path string) bool {
|
|||||||
|
|
||||||
// rm removes file in `path`.
|
// rm removes file in `path`.
|
||||||
pub fn rm(path string) ? {
|
pub fn rm(path string) ? {
|
||||||
|
mut rc := 0
|
||||||
$if windows {
|
$if windows {
|
||||||
rc := 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 {
|
||||||
rc := C.remove(charptr(path.str))
|
rc = C.remove(charptr(path.str))
|
||||||
if rc == -1 {
|
}
|
||||||
return error(posix_get_error_msg(C.errno))
|
if rc == -1 {
|
||||||
}
|
return error('Failed to remove "$path": ' + posix_get_error_msg(C.errno))
|
||||||
}
|
}
|
||||||
// C.unlink(path.cstr())
|
// C.unlink(path.cstr())
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user