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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!news.unit0.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Bill Findlay Newsgroups: comp.lang.ada Subject: Re: File name wild cards Date: Thu, 16 Aug 2018 15:29:30 +0100 Organization: none Message-ID: <0001HW.2125C1CA0B5125F370000F8CF2CF@news.individual.net> References: <0001HW.2124C8650B16B24770000F8CF2CF@news.individual.net> Reply-To: findlaybill@blueyonder.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: individual.net icdX0lgBy6Xe1lUnn/V6igx2KKDwxVDu4k8ljoDvetO000vZjC X-Orig-Path: not-for-mail Cancel-Lock: sha1:e7vX4Afh7rjbR9n0sYlGh75ipX0= User-Agent: Hogwasher/5.19 Xref: reader02.eternal-september.org comp.lang.ada:54182 Date: 2018-08-16T15:29:30+01:00 List-Id: On 16 Aug 2018, Dmitry A. Kazakov wrote (in article ): > 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 Thanks for those suggestions, Dmitry. My program is non-GUI, and I want to avoid using any non-Ada.* libraries. -- Bill Findlay