diff --git a/vlib/builtin/cfns.c.v b/vlib/builtin/cfns.c.v index 08314c1fff..413c50087b 100644 --- a/vlib/builtin/cfns.c.v +++ b/vlib/builtin/cfns.c.v @@ -291,7 +291,7 @@ fn C._putenv() int fn C._waccess() int -fn C._wremove() +fn C._wremove() int fn C.ReadConsole() voidptr diff --git a/vlib/os/os.v b/vlib/os/os.v index 894db5264a..af6cc1a832 100644 --- a/vlib/os/os.v +++ b/vlib/os/os.v @@ -628,12 +628,21 @@ pub fn file_exists(_path string) bool { } // rm removes file in `path`. -pub fn rm(path string) { +pub fn rm(path string) ? { $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 { - 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()) } // rmdir removes a specified directory.