X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-psi;a=blobdiff_plain;f=psi.d%2Fglob.psi;h=1fd6b15c9bb6f8677a96c232acb0802877ee50f1;hp=ce6f5a72c3510a2758c63e5533e3203b545952d3;hb=601e13c0743234c53a62e68fc89f122069123c15;hpb=cfebc76ed7426836f21296cca9a14b422bfa04cf diff --git a/psi.d/glob.psi b/psi.d/glob.psi index ce6f5a7..1fd6b15 100644 --- a/psi.d/glob.psi +++ b/psi.d/glob.psi @@ -1,15 +1,27 @@ -function psi\glob(string $pattern, int $flags, array &$glob = NULL) : int { +#include + +function psi\glob(string $pattern, int $flags, array &$glob = NULL, callable $errfn = NULL) : int { let path = strval($pattern); let flags = intval($flags); - let err = NULL; - let buf = arrval($glob); - return to_int(glob); + let err = callback intval($errfn( + to_string(epath), + to_int(eerrno) + )); + let buf = &arrval($glob, + intval($gl_matchc), + intval($gl_pathc), + intval($gl_offs), + intval($gl_flags), + &arrval($gl_pathv, + strval($gl_pathv) + ) + ); + return glob(path, flags, err, buf) as to_int(glob); set $glob = to_array(*buf, to_int(gl_matchc), to_int(gl_pathc), to_int(gl_offs), to_int(gl_flags), - to_array(gl_pathv, gl_pathc + gl_offs, to_string(gl_pathv)) + to_array(*gl_pathv, gl_pathc + gl_offs, to_string(*gl_pathv)) ); - free globfree(buf); }