From 57d9e177cce10214c082971155459b7f0aefd953 Mon Sep 17 00:00:00 2001 From: Vincent Celier Date: Tue, 31 Oct 2006 19:12:50 +0100 Subject: [PATCH] a-direct.ads, [...] (Search): New procedure in Ada 2005 2006-10-31 Vincent Celier * a-direct.ads, a-direct.adb (Search): New procedure in Ada 2005 From-SVN: r118322 --- gcc/ada/a-direct.adb | 26 +++++++++++++++++++++++++- gcc/ada/a-direct.ads | 20 +++++++++++++++++++- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/gcc/ada/a-direct.adb b/gcc/ada/a-direct.adb index 2cd29ed380b8..694ad8c5ef99 100644 --- a/gcc/ada/a-direct.adb +++ b/gcc/ada/a-direct.adb @@ -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 -- ------------------- diff --git a/gcc/ada/a-direct.ads b/gcc/ada/a-direct.ads index 3e2a2b239c40..aee3fb42199e 100644 --- a/gcc/ada/a-direct.ads +++ b/gcc/ada/a-direct.ads @@ -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 -- ------------------------------------- -- 2.43.5