Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

FindFirstFile and FindNextFile under UNIX

550 views
Skip to first unread message

Meir Dukhan

unread,
Feb 16, 1998, 3:00:00 AM2/16/98
to

Hi,


I'm looking for an implementation of these 2 Win32 functions.

FindFirstFile saerches a directory for a file whose name matches the
specified filename (or pattern),

FindNextFile continues a file search from a previous call to the
FindFirstFile (above) function.

I know, I could play with scandir(3) and some source code of bash
(glob.c) but I would like not to re-invent the wheel ;-)


Tia

Meir


Reinhold J. Gerharz

unread,
Feb 16, 1998, 3:00:00 AM2/16/98
to

Your in luck! UNIX has getdirentries(), which will get a whole bunch
of files in one system call.

Meir Dukhan <me...@bis.co.il> wrote:

--
Reinhold J. Gerharz http://www.erols.com/rgerharz/
PGP Key at http://www.erols.com/rgerharz/pgp/public-key.asc
"The only good spammer is a DEAD spammer!" - Anonymous

Kaz Kylheku

unread,
Feb 17, 1998, 3:00:00 AM2/17/98
to

In article <34e8c7bc....@news.erols.com>,

Reinhold J. Gerharz <rger...@erols.com> wrote:
>Your in luck! UNIX has getdirentries(), which will get a whole bunch
>of files in one system call.

Isn't that a BSD-ism? In any case, it does not do pattern globbing,
so you might as well use the POSIX functions opendir(), readdir()
et al.

For pattern matching, you want the POSIX.2 glob() function.

Meir Dukhan

unread,
Feb 17, 1998, 3:00:00 AM2/17/98
to k...@cafe.net

Kaz Kylheku wrote:


Thanks for your answer,

Could you please tell me if scandir(3) is POSIX.2 ?

Tia

Meir


Andrew Gierth

unread,
Feb 17, 1998, 3:00:00 AM2/17/98
to

[comp.lang.c removed from newsgroups header]

>>>>> "Meir" == Meir Dukhan <me...@bis.co.il> writes:

Meir> Could you please tell me if scandir(3) is POSIX.2 ?

I don't believe so; I think it's a BSDism. It's not in the Single Unix
specs.

fnmatch() is, though (both Posix.2 and the Unix spec), and
Find{First,Next}File can be implemented fairly straightforwardly using
opendir(), readdir(), and fnmatch().

If someone wants to submit an example for the FAQ, or even just a
specification for FindFirst/FindNext so I can whomp up an example,
then feel free.

--
Andrew.

comp.unix.programmer FAQ: see <URL: http://www.erlenstar.demon.co.uk/unix/>
or <URL: http://www.whitefang.com/unix/>

Bob Nelson

unread,
Feb 17, 1998, 3:00:00 AM2/17/98
to

In comp.lang.c Meir Dukhan <me...@bis.co.il> wrote:
> Kaz Kylheku wrote:

> > In article <34e8c7bc....@news.erols.com>,
> > Reinhold J. Gerharz <rger...@erols.com> wrote:
> > >Your in luck! UNIX has getdirentries(), which will get a whole bunch
> > >of files in one system call.
> >
> > Isn't that a BSD-ism? In any case, it does not do pattern globbing,
> > so you might as well use the POSIX functions opendir(), readdir()
> > et al.
> >
> > For pattern matching, you want the POSIX.2 glob() function.

> Thanks for your answer,

> Could you please tell me if scandir(3) is POSIX.2 ?

``CONFORMING TO BSD 4.3''

--
========================================================================
Bob Nelson -- Dallas, Texas, USA (bne...@iname.com)
http://www.geocities.com/ResearchTriangle/6375
========================================================================

firewind

unread,
Feb 17, 1998, 3:00:00 AM2/17/98
to

On Tue, 17 Feb 1998, Meir Dukhan wrote:

> Could you please tell me if scandir(3) is POSIX.2 ?

Why don't you try the man page? Or perhaps comp.unix.programmer?

--
Attempting to write in a hybrid which can be compiled by either a C compiler
or a C++ compiler produces a compromise language which combines the drawbacks
of both with the advantages of neither.
-- John Winters <jo...@polo.demon.co.uk> in comp.lang.c


0 new messages