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

os: realpath potential fix

This commit is contained in:
Alexander Medvednikov 2019-11-15 01:07:38 +03:00
parent bf669012e7
commit bd97dc0134
2 changed files with 11 additions and 3 deletions

View File

@ -25,6 +25,8 @@ fn backtrace_symbols_fd(voidptr, int, int)
// <libproc.h>
fn proc_pidpath(int, voidptr, int) int
fn C.realpath(byteptr, byteptr) &char
// Windows

View File

@ -833,9 +833,15 @@ pub fn realpath(fpath string) string {
res = int( C._fullpath( fullpath, fpath.str, MAX_PATH ) )
}
$else{
// here we want an int==0 if realpath failed, in which case
// realpath would return NULL, and !isnil(NULL) would be false==0
res = int( !isnil(C.realpath( fpath.str, fullpath )) )
if fpath.len != strlen(fpath.str) {
l := strlen(fpath.str)
println('FIXME realpath diff len $fpath.len strlen=$l')
}
ret := C.realpath(fpath.str, fullpath)
if ret == 0 {
return fpath
}
return string(fullpath)
}
if res != 0 {
return string(fullpath, vstrlen(fullpath))