a-direct.ads, [...] (Search): New procedure in Ada 2005
authorVincent Celier <celier@adacore.com>
Tue, 31 Oct 2006 18:12:50 +0000 (19:12 +0100)
committerArnaud Charlet <charlet@gcc.gnu.org>
Tue, 31 Oct 2006 18:12:50 +0000 (19:12 +0100)
2006-10-31  Vincent Celier  <celier@adacore.com>

* a-direct.ads, a-direct.adb (Search): New procedure in Ada 2005

From-SVN: r118322

gcc/ada/a-direct.adb
gcc/ada/a-direct.ads

index 2cd29ed380b8e192bc70781c410c1f0c7153076b..694ad8c5ef990cddc01d87c860a4c789adbf6da5 100644 (file)
@@ -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 --
    -------------------
index 3e2a2b239c4002b9c694fd55a988e88df588c0c6..aee3fb42199eb6cbebcead0125110cba30cca190 100644 (file)
@@ -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 --
    -------------------------------------