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

pull/6039/head
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
1 changed files with 2 additions and 3 deletions

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)
if C.CopyFile(w_old.to_wide(), w_new.to_wide(), false) == 0 {
result := C.GetLastError()
if result != 0 {
return error_with_code('failed to copy $old to $new', int(result))
}
} $else {