Fix for the (stupid) case of app (always) passing
[tangerine.git] / rom / dos / matchfirst.c
blobccd33498748c7fa3b0ab7b8bd08b8a910d6278cc
1 /*
2 Copyright © 1995-2001, 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(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 the directory
36 the files is in in ap_Current->an_Lock. After the first call to
37 MatchFirst() call MatchNext().
38 The search begins whereever the current directory is set to. See
39 CurrentDir();
40 For more info on patterns see ParsePattern().
42 INPUTS
43 pat - pattern to search for
44 AP - pointer to (initilized) AnchorPath structure
46 RESULT
47 0 = success
48 other = DOS error code
50 NOTES
52 EXAMPLE
54 BUGS
56 SEE ALSO
57 MatchNext(), MatchEnd(), ParsePattern(), Examine(), CurrentDir()
58 <dos/dosasl.h>
60 INTERNALS
62 *****************************************************************************/
64 AROS_LIBFUNC_INIT
65 AROS_LIBBASE_EXT_DECL(struct DosLibrary *,DOSBase)
67 struct AChain *ac;
68 LONG error;
70 AP->ap_Flags = 0;
71 AP->ap_Base = 0;
72 AP->ap_Current = 0;
74 error = Match_BuildAChainList(pat, AP, &ac, DOSBase);
75 if (error == 0)
77 AP->ap_Base = AP->ap_Current = ac;
79 error = MatchNext(AP);
81 } /* if (error == 0) */
83 SetIoErr(error);
85 return error;
87 AROS_LIBFUNC_EXIT
89 } /* MatchFirst */