Index: a-direct.ads =================================================================== --- a-direct.ads (revision 118179) +++ a-direct.ads (working copy) @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 2004-2005, Free Software Foundation, Inc. -- +-- Copyright (C) 2004-2006, Free Software Foundation, Inc. -- -- -- -- This specification is derived for use with GNAT from AI-00248, which is -- -- expected to be a part of a future expected revised Ada Reference Manual. -- @@ -340,6 +340,24 @@ package Ada.Directories is -- environment does not support continued searching of the directory -- represented by Search. + procedure Search + (Directory : String; + Pattern : String; + Filter : Filter_Type := (others => True); + Process : not null access procedure + (Directory_Entry : Directory_Entry_Type)); + -- Searches in the directory named by Directory for entries matching + -- Pattern. The subprogram designated by Process is called with each + -- matching entry in turn. Pattern represents a pattern for matching file + -- names. If Pattern is null, all items in the directory are matched; + -- otherwise, the interpretation of Pattern is implementation-defined. + -- Only items that match Filter will be returned. The exception Name_Error + -- is propagated if the string given by Directory does not identify + -- an existing directory, or if Pattern does not allow the identification + -- of any possible external file or directory. The exception Use_Error is + -- propagated if the external environment does not support the searching + -- of the directory with the given name (in the absence of Name_Error). + ------------------------------------- -- Operations on Directory Entries -- ------------------------------------- Index: a-direct.adb =================================================================== --- a-direct.adb (revision 118179) +++ a-direct.adb (working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 2004-2005, Free Software Foundation, Inc. -- +-- Copyright (C) 2004-2006, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -835,6 +835,30 @@ package body Ada.Directories is end if; end Rename; + ------------ + -- Search -- + ------------ + + procedure Search + (Directory : String; + Pattern : String; + Filter : Filter_Type := (others => True); + Process : not null access procedure + (Directory_Entry : Directory_Entry_Type)) + is + Srch : Search_Type; + Directory_Entry : Directory_Entry_Type; + begin + Start_Search (Srch, Directory, Pattern, Filter); + + while More_Entries (Srch) loop + Get_Next_Entry (Srch, Directory_Entry); + Process (Directory_Entry); + end loop; + + End_Search (Srch); + end Search; + ------------------- -- Set_Directory -- -------------------