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!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: File name wild cards Date: Thu, 16 Aug 2018 09:47:31 +0200 Organization: Aioe.org NNTP Server Message-ID: References: <0001HW.2124C8650B16B24770000F8CF2CF@news.individual.net> NNTP-Posting-Host: MyFhHs417jM9AgzRpXn7yg.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 Content-Language: en-US X-Notice: Filtered by postfilter v. 0.8.3 Xref: reader02.eternal-september.org comp.lang.ada:54176 Date: 2018-08-16T09:47:31+02:00 List-Id: On 2018-08-15 22:45, 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. > Worse, I cannot find any interpretation in the GNAT documentation. AFAIK Ada.Directories is non-portable anyway. I hope this will be fixed in Ada 2020 in a way that would abstract the file system as a set of nice ADTs. I do portable file lookup this admittedly ugly way: 1. I use Ada bindings to GLib. GLib has portable directory walk, which maintains UTF-8 names regardless the underlying OS: http://www.dmitry-kazakov.de/ada/gtkada_contributions.htm#5 Dir_Open, Dir_Read_Name etc. 2. I check names for artifacts like "." and ".." and translate \ to /. 3. I use wild-card matcher for UTF-8 encoded strings: http://www.dmitry-kazakov.de/ada/strings_edit.htm#7.5 -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de