From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Re: File name wild cards Date: Thu, 16 Aug 2018 09:46:49 +0200 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: <0001HW.2124C8650B16B24770000F8CF2CF@news.individual.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Thu, 16 Aug 2018 07:46:53 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="d8e838c19e1f4a700525e11843de3a5d"; logging-data="28526"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1817rCPw+df/53lB+bH9sAYpeXvIgaWLt8=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 Cancel-Lock: sha1:WSrzSO9xzaZj6NhFzsNFisgxiC0= In-Reply-To: <0001HW.2124C8650B16B24770000F8CF2CF@news.individual.net> Content-Language: en-US Xref: reader02.eternal-september.org comp.lang.ada:54175 Date: 2018-08-16T09:46:49+02:00 List-Id: On 08/15/2018 10:45 PM, Bill Findlay wrote: > Can anyone point me to a portable way of doing wildcard filename lookups? > > In Ada.Directories we have; > >> type Search_Type is limited private; >> procedure Start_Search (Search: in out Search_Type; >> Directory: in String; >> Pattern: in String; >> Filter: in Filter_Type := (others => True)); > > etc > But the interpretation of Pattern is implementation defined. I interpret this as being like the Form parameter for opening a file. It's whatever's meaningful for the actual platform being used. There's no way to be completely portable, since even the way one specifies a directory can vary significantly between file systems. Assuming you have a way of specifying the directory that is acceptably portable for your uses, one way to portably select only files that match some pattern is to pass Pattern => "" and select files that match your pattern internally, perhaps using a regular-expression pkg. However, if by portable you mean between Unix-like and Windows systems, and you restrict yourself to the current directory (or directories you can construct from it using Hierarchical_File_Names), then I've found that '*' and '?' are portable enough for my needs. For example, the program that selected the signature on this msg used Directory => "." and Pattern => "signature???.txt". -- Jeff Carter "Have you gone berserk? Can't you see that that man is a ni?" Blazing Saddles 38