From 515d8c0bc89e94b0584b94fe9ebd77bc9796673d Mon Sep 17 00:00:00 2001 From: Bastian Buck <59334447+bstnbuck@users.noreply.github.com> Date: Sat, 17 Apr 2021 01:37:57 +0200 Subject: [PATCH] os: remove unnecessary check (#9722) (#9773) --- vlib/os/os_c.v | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/vlib/os/os_c.v b/vlib/os/os_c.v index 9b398ed08b..6b93841732 100644 --- a/vlib/os/os_c.v +++ b/vlib/os/os_c.v @@ -134,8 +134,9 @@ pub fn read_file(path string) ?string { } // ***************************** OS ops ************************ - +// // truncate changes the size of the file located in `path` to `len`. +// Note that changing symbolic links on Windows only works as admin. pub fn truncate(path string, len u64) ? { fp := C.open(&char(path.str), o_wronly | o_trunc) defer { @@ -155,7 +156,9 @@ pub fn truncate(path string, len u64) ? { } } -// file_size returns the size of the file located in `path`. In case of error -1 is returned. +// file_size returns the size of the file located in `path`. +// If an error occurs it returns 0. +// Note that use of this on symbolic links on Windows returns always 0. pub fn file_size(path string) u64 { mut s := C.stat{} unsafe { @@ -182,7 +185,7 @@ pub fn file_size(path string) u64 { } } } - return -1 + return 0 } // mv moves files or folders from `src` to `dst`. @@ -868,12 +871,8 @@ pub fn chown(path string, owner int, group int) ? { $if windows { return error('os.chown() not implemented for Windows') } $else { - if owner < 0 || group < 0 { - return error('os.chown() uid and gid cannot be negative: Not changing owner!') - } else { - if C.chown(&char(path.str), owner, group) != 0 { - return error_with_code(posix_get_error_msg(C.errno), C.errno) - } + if C.chown(&char(path.str), owner, group) != 0 { + return error_with_code(posix_get_error_msg(C.errno), C.errno) } } }