ADA - 使用模式搜索目录 - 没有按预期返回

ADA - Searching a directory with a pattern - not returning as it should

我的程序的这一部分应该列出名称中包含“.txt”的目录中的所有文件,但在 运行 时它不返回任何内容。如果我删除“.txt”并将其保留为空字符串“”,那么它会完美地工作并且 returns 所有文件名包括 .txt 文件所以我不知道我在这里做错了什么。

  procedure Search_Directory is
      use Ada.Directories;
      
      procedure Write_Search_Item(Search_Item : in Directory_Entry_Type) is
      begin
         Put(Item => Simple_Name(Directory_Entry => Search_Item));
         New_Line;
      end Write_Search_Item;

      Filter : Constant Filter_Type := (Ordinary_File => True,
                                        Special_File => False,
                                        Directory => True);         
   begin
      Search(Directory => Current_Directory,
             Pattern => (".txt"),
             Filter => Filter,
             Process => Write_Search_Item'Access);           
   end Search_Directory;

Ada.Directories 中定义的 Search 函数采用模式参数,该参数可以是空字符串或实现定义的形式 RM A.16 (111/ 2). In GNAT, this pattern is supposed to be a regular expression (see also here) described in System.Regexp (see also here,第二个语法,一个“通配模式”)。