PR c++/54038
[official-gcc.git] / gcc / ada / g-diopit.ads
blobaac30b957fbedc24edd0bce932096acc07be56cc
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- G N A T . D I R E C T O R Y _ O P E R A T I O N S . I T E R A T I O N --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 2001-2010, AdaCore --
10 -- --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. --
17 -- --
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
19 -- additional permissions described in the GCC Runtime Library Exception, --
20 -- version 3.1, as published by the Free Software Foundation. --
21 -- --
22 -- You should have received a copy of the GNU General Public License and --
23 -- a copy of the GCC Runtime Library Exception along with this program; --
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
25 -- <http://www.gnu.org/licenses/>. --
26 -- --
27 -- GNAT was originally developed by the GNAT team at New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
29 -- --
30 ------------------------------------------------------------------------------
32 -- Iterators among files
34 package GNAT.Directory_Operations.Iteration is
36 generic
37 with procedure Action
38 (Item : String;
39 Index : Positive;
40 Quit : in out Boolean);
41 procedure Find
42 (Root_Directory : Dir_Name_Str;
43 File_Pattern : String);
44 -- Recursively searches the directory structure rooted at Root_Directory.
45 -- This provides functionality similar to the UNIX 'find' command.
46 -- Action will be called for every item matching the regular expression
47 -- File_Pattern (see GNAT.Regexp). Item is the full pathname to the file
48 -- starting with Root_Directory that has been matched. Index is set to one
49 -- for the first call and is incremented by one at each call. The iterator
50 -- will pass in the value False on each call to Action. The iterator will
51 -- terminate after passing the last matched path to Action or after
52 -- returning from a call to Action which sets Quit to True.
53 -- Raises GNAT.Regexp.Error_In_Regexp if File_Pattern is ill formed.
55 generic
56 with procedure Action
57 (Item : String;
58 Index : Positive;
59 Quit : in out Boolean);
60 procedure Wildcard_Iterator (Path : Path_Name);
61 -- Calls Action for each path matching Path. Path can include wildcards '*'
62 -- and '?' and [...]. The rules are:
64 -- * can be replaced by any sequence of characters
65 -- ? can be replaced by a single character
66 -- [a-z] match one character in the range 'a' through 'z'
67 -- [abc] match either character 'a', 'b' or 'c'
69 -- Item is the filename that has been matched. Index is set to one for the
70 -- first call and is incremented by one at each call. The iterator's
71 -- termination can be controlled by setting Quit to True. It is by default
72 -- set to False.
74 -- For example, if we have the following directory structure:
75 -- /boo/
76 -- foo.ads
77 -- /sed/
78 -- foo.ads
79 -- file/
80 -- foo.ads
81 -- /sid/
82 -- foo.ads
83 -- file/
84 -- foo.ads
85 -- /life/
87 -- A call with expression "/s*/file/*" will call Action for the following
88 -- items:
89 -- /sed/file/foo.ads
90 -- /sid/file/foo.ads
92 end GNAT.Directory_Operations.Iteration;