comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: File name wild cards
Date: Thu, 16 Aug 2018 09:47:31 +0200
Date: 2018-08-16T09:47:31+02:00	[thread overview]
Message-ID: <pl3a6i$15s1$1@gioia.aioe.org> (raw)
In-Reply-To: 0001HW.2124C8650B16B24770000F8CF2CF@news.individual.net

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

  parent reply	other threads:[~2018-08-16  7:47 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 [this message]
2018-08-16 14:29   ` Bill Findlay
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox