Repository navigation
os: fix windows rmdir GetLastError() - #24357
Conversation
|
Connected to Huly®: V_0.6-22733 |
|
For me, the test in the issue passes with all compilers on master: |
|
The other remaining call does: @[inline; manualfree]
pub fn error_win32(e SystemError) IError {
$if windows {
code := if e.code == error_code_not_set { int(C.GetLastError()) } else { e.code }
message := if e.msg == '' { get_error_msg(code) } else { e.msg }
return error_with_code(message, code)
} $else {
panic('Win32 API not available on this platform.')
}
} we also have: Is it possible that "magic" constant is not so magic, and has to be changed to some value that is not actually used as a return error? |
|
According to this: https://learn.microsoft.com/en-us/windows/win32/debug/system-error-codes all system error codes are positive numbers. Can we use |
|
I think there should be some system calls in |
also, |
Yes, I agree |
|
bad news:
pub fn rmdir(path string) ! {
$if windows {
rc := C.RemoveDirectory(path.to_wide())
if !rc {
// https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-removedirectorya - 0 == false, is failure
_ := 'Failed to remove "${path}"'
code := int(C.GetLastError()) // here , we get error code 0, which is overwritten by previous `str_intp`
dump(code)
return error_win32( msg: 'Failed to remove "${path}"')
}
} $else {
rc := C.rmdir(&char(path.str))
if rc == -1 {
return error_posix()
}
}
} |
I have not thought about that at all 🤦🏻♂️. Good find. |
spytheman
left a comment
There was a problem hiding this comment.
Excellent work and investigation.
Fix #24356
If not set
code,error_win32()will callC.GetLastError()again and get a zero value.