try to make sure compiler/include/mmakefile is always refreshed correctly.
[AROS.git] / rom / dos / matchfirst.c
blob026150902ab1e50321cb2ee211602af702e892b5
1 /*
2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: english
7 */
8 #include "dos_intern.h"
9 #include <proto/exec.h>
10 #include <exec/memory.h>
11 #include <exec/types.h>
12 #include <dos/dos.h>
14 /*****************************************************************************
16 NAME */
17 #include <dos/dosasl.h>
18 #include <proto/dos.h>
20 AROS_LH2(LONG, MatchFirst,
22 /* SYNOPSIS */
23 AROS_LHA(CONST_STRPTR , pat, D1),
24 AROS_LHA(struct AnchorPath *, AP , D2),
26 /* LOCATION */
27 struct DosLibrary *, DOSBase, 137, Dos)
29 /* FUNCTION
30 Searches for the first file or directory that matches a given pattern.
31 MatchFirst() initializes the AnchorPath structure for you but you
32 must initilize the following fields: ap_Flags, ap_Strlen, ap_BreakBits
33 and ap_FoundBreak. The first call to MatchFirst() also passes you
34 the first matching file, which you can examine in ap_Info, and
35 the directory the file is in, in ap_Current->an_Lock. After the first
36 call to MatchFirst(), call MatchNext(). The search begins wherever the
37 current directory is set to (see CurrentDir()). For more info on
38 patterns, see ParsePattern().
40 INPUTS
41 pat - pattern to search for
42 AP - pointer to (initilized) AnchorPath structure
44 RESULT
45 0 = success
46 other = DOS error code
48 NOTES
50 EXAMPLE
52 BUGS
54 SEE ALSO
55 MatchNext(), MatchEnd(), ParsePattern(), Examine(), CurrentDir()
56 <dos/dosasl.h>
58 INTERNALS
60 *****************************************************************************/
62 AROS_LIBFUNC_INIT
64 struct AChain *ac;
65 LONG error;
67 AP->ap_Flags = 0;
68 AP->ap_Base = 0;
69 AP->ap_Current = 0;
71 error = Match_BuildAChainList(pat, AP, &ac, DOSBase);
72 if (error == 0)
74 AP->ap_Base = AP->ap_Current = ac;
76 error = MatchNext(AP);
78 } /* if (error == 0) */
80 SetIoErr(error);
82 return error;
84 AROS_LIBFUNC_EXIT
86 } /* MatchFirst */