[Gambas-user] Exist with wildcard

bb adamnt42 at gmail.com
Wed Aug 4 12:51:13 CEST 2021


On Wed, 2021-08-04 at 12:45 +0200, Tobias Boege via User wrote:
> On Wed, 04 Aug 2021, bb wrote:
> > I am trying to determine if a particular library has been installed
> > in
> > a particular diectory. 
> > 
> > I was sure Exist(path) took wildcards into account, but it doen't
> > seem
> > so.  Any ideas on how to do a wildcard search for a file then?
> > 
> > e.g. I am looking for "ph.internals:*.gambas" in
> > "/srv/gbshared/lib".
> > The actual file is "ph.internals:1.0.gambas" i.e. it has the
> > library
> > version included in it, but I don't know WHAT version I am looking
> > for.
> > 
> 
> Exist() doesn't understand wildcards, but Dir() does, but not with
> the
> same syntax as the shell, but with Gambas's LIKE syntax. You can use
> 
>   If Dir("/srv/gbshared/lib", "ph.internals:*.gambas", gb.File).Count
> > 0 Then
>   ...
> 
> This does not short-circuit to returning True as soon as a file
> matching
> the pattern is found, but always gives you the entire array of all
> matches
> before you call Count on it, but probably that's not a critical
> overhead.
> 
> Best,
> Tobias
> 
Ah, of course! (Smacks head on keyboard).

Your answer crossed over with me trying to explain the issue.

Thanks

bruce



More information about the User mailing list