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

os: make chdir() return error

This commit is contained in:
Alexander Medvednikov
2021-08-28 09:35:39 +03:00
parent e85311c2ba
commit 858ba25d55
12 changed files with 25 additions and 26 deletions

View File

@ -744,11 +744,10 @@ pub fn is_link(path string) bool {
}
// chdir changes the current working directory to the new directory in `path`.
pub fn chdir(path string) {
$if windows {
C._wchdir(path.to_wide())
} $else {
_ = C.chdir(&char(path.str))
pub fn chdir(path string) ? {
ret := $if windows { C._wchdir(path.to_wide()) } $else { C.chdir(&char(path.str)) }
if ret == -1 {
return error_with_code(posix_get_error_msg(C.errno), C.errno)
}
}