Detabbed
[AROS.git] / rom / dos / matchfirst.c
blobe7a58ab1dd364c458459a3d219f8be8ab7b98cba
1 /*
2 Copyright © 1995-2008, 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
31 Searches for the first file or directory that matches a given pattern.
32 MatchFirst() initializes the AnchorPath structure for you but you
33 must initilize the following fields: ap_Flags, ap_Strlen, ap_BreakBits
34 and ap_FoundBreak. The first call to MatchFirst() also passes you
35 the first matching file, which you can examine in ap_Info, and
36 the directory the file is in, in ap_Current->an_Lock. After the first
37 call to MatchFirst(), call MatchNext(). The search begins wherever the
38 current directory is set to (see CurrentDir()). For more info on
39 patterns, see ParsePattern().
41 INPUTS
42 pat - pattern to search for
43 AP - pointer to (initilized) AnchorPath structure
45 RESULT
46 0 = success
47 other = DOS error code
49 NOTES
51 EXAMPLE
53 BUGS
55 SEE ALSO
56 MatchNext(), MatchEnd(), ParsePattern(), Examine(), CurrentDir()
57 <dos/dosasl.h>
59 INTERNALS
61 *****************************************************************************/
63 AROS_LIBFUNC_INIT
65 struct AChain *ac;
66 LONG error;
68 AP->ap_Flags = 0;
69 AP->ap_Base = 0;
70 AP->ap_Current = 0;
72 error = Match_BuildAChainList(pat, AP, &ac, DOSBase);
73 if (error == 0)
75 AP->ap_Base = AP->ap_Current = ac;
77 error = MatchNext(AP);
79 } /* if (error == 0) */
81 SetIoErr(error);
83 return error;
85 AROS_LIBFUNC_EXIT
87 } /* MatchFirst */