X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=psi.d%2Fglob.psi;h=19aa6cb951b02676eda1b74c3ba3ec99bec9c810;hb=5298e4d033b2d6ff41a81311ec52c9c9b2c82b22;hp=2bb952e57e6c7dc8bbae6d446abd555549544c06;hpb=b4508f6b917660970f887894a6aaed6c220a2c72;p=m6w6%2Fext-psi diff --git a/psi.d/glob.psi b/psi.d/glob.psi index 2bb952e..19aa6cb 100644 --- a/psi.d/glob.psi +++ b/psi.d/glob.psi @@ -1,15 +1,18 @@ -function psi\glob(string $pattern, int $flags, array &$glob = NULL) : int { +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); + let err = callback intval($errfn( + to_string(epath), + to_int(eerrno) + )); + let buf = &arrval($glob); return 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); }