pe*alloc
[m6w6/ext-psi] / psi.d / glob.psi
1 #include <glob.h>
2
3 function psi\glob(string $pattern, int $flags, array &$glob = NULL, callable $errfn = NULL) : int {
4 let path = strval($pattern);
5 let flags = intval($flags);
6 let err = callback(
7 epath,
8 eerrno
9 ) as intval($errfn(
10 to_string(epath),
11 to_int(eerrno)
12 ));
13 let buf = &arrval($glob,
14 intval($gl_matchc),
15 intval($gl_pathc),
16 intval($gl_offs),
17 intval($gl_flags),
18 &arrval($gl_pathv,
19 strval($gl_pathv)
20 )
21 );
22 return glob(path, flags, err, buf) as to_int(glob);
23 set $glob = to_array(*buf,
24 to_int(gl_matchc),
25 to_int(gl_pathc),
26 to_int(gl_offs),
27 to_int(gl_flags),
28 to_array(*gl_pathv, gl_pathc + gl_offs, to_string(*gl_pathv))
29 );
30 free globfree(buf);
31 }