os: fix realpath on windows

pull/2856/head
Alexander Medvednikov 2019-11-23 20:56:22 +03:00
parent 1bd8c465d3
commit 0aa2196eec
1 changed files with 5 additions and 6 deletions

View File

@ -869,9 +869,11 @@ pub fn realpath(fpath string) string {
mut fullpath := calloc( MAX_PATH )
mut res := 0
$if windows {
// here we want an int==0 if _fullpath failed , in which case
// it would return NULL, and !isnil(NULL) would be false==0
res = int( !isnil(C._fullpath( fullpath, fpath.str, MAX_PATH )) )
ret := C._fullpath(fpath.str, fullpath)
if ret == 0 {
return fpath
}
return string(fullpath)
}
$else{
ret := C.realpath(fpath.str, fullpath)
@ -880,9 +882,6 @@ pub fn realpath(fpath string) string {
}
return string(fullpath)
}
if res != 0 {
return string(fullpath, vstrlen(fullpath))
}
return fpath
}