From: Bill Findlay <findlaybill@blueyonder.co.uk>
Subject: Re: File name wild cards
Date: Thu, 16 Aug 2018 15:29:30 +0100
Date: 2018-08-16T15:29:30+01:00 [thread overview]
Message-ID: <0001HW.2125C1CA0B5125F370000F8CF2CF@news.individual.net> (raw)
In-Reply-To: pl3a6i$15s1$1@gioia.aioe.org
On 16 Aug 2018, Dmitry A. Kazakov wrote
(in article <pl3a6i$15s1$1@gioia.aioe.org>):
> 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
prev parent reply other threads:[~2018-08-16 14:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-15 20:45 File name wild cards Bill Findlay
2018-08-16 7:46 ` Jeffrey R. Carter
2018-08-16 14:26 ` Bill Findlay
2018-08-16 7:47 ` Dmitry A. Kazakov
2018-08-16 14:29 ` Bill Findlay [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox