; GLOB
;
; Program for Proteus
;
; (C) 1998-2004 Simone Zanella Productions
;
; Print the list of files corresponding to spec (that should be
; specified between double quotes).
; Implicit parameters: input and output are NULL
;!proteus -z
IF ISEMPTY(ARGV(5))
CONSOLELN "Syntax: " ARGV(1) " " ARGV(2) " \"spec\""
CONSOLELN ""
CONSOLELN "Purpose: list of files corresponding to \"spec\""
ABORT 0
FI
V = Glob(ARGV(5), 1)
FOR X = 1 TO VECLEN(V)
CONSOLELN VECGET(V, X)
NEXT
ABORT 0
FUNCTION Glob(dirspec, incdir)
q = QUEUENEW()
h = DIROPEN(dirspec, IIF(incdir, 3, 1))
f = IIF(NEQ(h, -1), 1, 0)
WHILE GT(f, 0)
; File found
ENQUEUE(q, DIRLAST(h, 1))
f = DIRNEXT(h)
LOOP
DIRCLOSE(h)
y = QUEUELEN(q)
v = VECNEW(y)
IF y
FOR X = 1 TO y
VECSET(v, X, DEQUEUE(q))
NEXT
FI
QUEUEFREE(q)
RETURN v