1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

os.cp: fix returning false error on Windows (#6037)

This commit is contained in:
Nick Treleaven 2020-08-02 12:08:45 +01:00 committed by GitHub
parent 7f447bb82f
commit 8dcc3cda97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -75,9 +75,8 @@ pub fn cp(old, new string) ? {
$if windows {
w_old := old.replace('/', '\\')
w_new := new.replace('/', '\\')
C.CopyFile(w_old.to_wide(), w_new.to_wide(), false)
result := C.GetLastError()
if result != 0 {
if C.CopyFile(w_old.to_wide(), w_new.to_wide(), false) == 0 {
result := C.GetLastError()
return error_with_code('failed to copy $old to $new', int(result))
}
} $else {