autoconf: split into subdirectories; redirect calls in debug builds
[m6w6/ext-psi] / psi.d / glob.psi
index 02d1c3d68811b4eb767239666d87f2fbded07ea4..61ada04bb65c7f0f41d9360c0ed8de1fff958d6c 100644 (file)
@@ -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(errmsg),
+               to_int(errno)
+       ));
+       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);
 }