summaryrefslogtreecommitdiffstats
path: root/tests/017/glob-carray.tl
blob: f98359a810fa00199579469ff3b4c6746a68d488 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
(load "../common")

(defstruct glob-t nil
  pathc pathv (reserve 0))

(cond
  ((eq (os-symbol) :macos)
   (deffi-type glob-t (struct glob-t
                        (pathc size-t)
                        (nil int)
                        (nil size-t)
                        (nil int)
                        (pathv (carray str-d))
                        (nil (array 4 cptr)))))
  (t (deffi-type glob-t (struct glob-t
                          (pathc size-t)
                          (pathv (carray str-d))
                          (reserve size-t)))))

(with-dyn-lib nil
  (deffi globb "glob" int (str int closure (ptr-out glob-t)))
  (deffi globfree "globfree" void ((ptr-in glob-t)))
  (deffi-cb glob-cb int (str int) -1))

(let* ((g (new glob-t)))
  (prinl (globb "tests/001/*.txr" 0 (glob-cb (lambda (path err))) g))
  (carray-set-length g.pathv g.pathc)
  (prinl g)
  (prinl (vec-carray g.pathv))
  (globfree g))