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:
parent
bf669012e7
commit
bd97dc0134
@ -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
|
||||
|
12
vlib/os/os.v
12
vlib/os/os.v
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user