comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: File name wild cards
Date: Thu, 16 Aug 2018 09:46:49 +0200
Date: 2018-08-16T09:46:49+02:00	[thread overview]
Message-ID: <pl3a5c$rre$1@dont-email.me> (raw)
In-Reply-To: <0001HW.2124C8650B16B24770000F8CF2CF@news.individual.net>

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


  reply	other threads:[~2018-08-16  7:46 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 [this message]
2018-08-16 14:26   ` Bill Findlay
2018-08-16  7:47 ` Dmitry A. Kazakov
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