4 * Read directories in a buffered way
6 * © 1998 Straylight/Edgeware
9 /*----- Licensing note ----------------------------------------------------*
11 * This file is part of Straylight's core utilities (coreutils).
13 * Coreutils is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2, or (at your option)
18 * Coreutils is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with coreutils. If not, write to the Free Software Foundation,
25 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 /*----- Header files ------------------------------------------------------*/
39 /*----- Main code ---------------------------------------------------------*/
41 /* --- @gf_init@ --- *
43 * Arguments: @gf_ctx *g@ = pointer to a context buffer for me
44 * @const char *pat@ = pointer to a (RISC OS) pattern string
45 * @cost char *dir@ = pointer to name of parent directory
49 * Use: Initialise a wildcard match context ready for scanning.
52 void gf_init(gf_ctx *g, const char *pat, const char *dir)
60 /* --- @gf_next@ --- *
62 * Arguments: @gf_ctx *g@ = pointer to my context
64 * Returns: Pointer to a filename, or zero for end
66 * Use: Returns the next matching file from the block.
69 char *gf_next(gf_ctx *g)
71 /* --- See if the buffer is empty --- */
75 /* --- Check for end of the list --- */
80 /* --- Fetch some more items from the list --- */
83 if (_swix(OS_GBPB, _inr(0, 6) | _out(3) | _out(4),
84 9, g->dir, g->buf, 1024, g->ctx, sizeof(g->buf), g->pat,
89 /* --- Dole out the next item from the list --- */
102 /*----- That's all, folks -------------------------------------------------*/