Directory/File recursive listing using standard/portable C?

I

ibic

Just curious: is it possible to recursively list all the
directorys/files inside a given directory using standard c i/o library
routines only, which can be re-compiled and run on any os supportes c
compiler? Or this is too os dependent, system-specific functions must
be called?
I think about this when i tried to do this under windows, i found in
order to achieve this, some windows-specific api such as
FindFirstFile, FindNextFile must be used, so anyway not using them?

Forgive my poor English, Thanks in advance.
 
L

Lew Pitcher

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Just curious: is it possible to recursively list all the
directorys/files inside a given directory using standard c i/o library
routines only,

Sorry, but standard C does not recognize the concept of a directory, and there
are no functions in the standard C library to list (recursively or otherwise)
the contents of directories.

You are going to have to look to an extension that supports such things. FWIW,
the POSIX extensions to C are useable under a large number of operating systems,
including all Unix-ish systems, and (so I am told) Microsoft Windows.

- --
Lew Pitcher
IT Consultant, Enterprise Data Systems,
Enterprise Technology Solutions, TD Bank Financial Group

(Opinions expressed are my own, not my employers')
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)

iD8DBQFBmRJeagVFX4UWr64RApeWAKClqSiabUpuryinHORf3Lrz7DpUFQCdEPGd
E4jOFEQUvljD0ASNp5sndG8=
=MPTi
-----END PGP SIGNATURE-----
 
B

Barry Schwarz

Just curious: is it possible to recursively list all the
directorys/files inside a given directory using standard c i/o library
routines only, which can be re-compiled and run on any os supportes c
compiler? Or this is too os dependent, system-specific functions must
be called?
I think about this when i tried to do this under windows, i found in
order to achieve this, some windows-specific api such as
FindFirstFile, FindNextFile must be used, so anyway not using them?

And you should be aware that there are major operating systems which
don't use directories at all.


<<Remove the del for email>>
 
D

Dan Pop

In said:
And you should be aware that there are major operating systems which
don't use directories at all.

Calling them "major" is a bit of an exaggeration, these days. "Legacy"
is a more appropriate term.

Dan
 
B

Barry Schwarz

rOn said:
Calling them "major" is a bit of an exaggeration, these days. "Legacy"
is a more appropriate term.

*I* have a hard time calling something whose newest release is less
than a year old "legacy". *B*ut I don't have a hard time calling
something that generates hundreds of millions of dollars of revenue
for its vendor "major". *M*aybe we just look at things differently.


<<Remove the del for email>>
 
C

Charlie Gordon

Barry Schwarz said:
*I* have a hard time calling something whose newest release is less
than a year old "legacy". *B*ut I don't have a hard time calling
something that generates hundreds of millions of dollars of revenue
for its vendor "major". *M*aybe we just look at things differently.

Please Master, break the news upon us...
Let us in on this major secret...
Deliver us from evil directory trees !
Let the world be flat again !

Chqrlie
 
D

Dan Pop

In said:
*I* have a hard time calling something whose newest release is less
than a year old "legacy". *B*ut I don't have a hard time calling
something that generates hundreds of millions of dollars of revenue
for its vendor "major". *M*aybe we just look at things differently.

It might be a major product for its vendor, it's still a legacy OS for
those stuck with it. At a previous job, one of the main reasons they
decided to get rid of their large mainframe configuration was precisely
the lack of directory support.

Dan
 
M

Michael Wojcik

Please Master, break the news upon us...
Let us in on this major secret...

It's hardly a secret. A little research would suffice to identify
operating systems that do not use hierarchical-directory filesystems
(at least for their dominant filesystem), or use something which may
resemble a hierarchical-directory filesystem in some respects but not
in others (so that the OP's project would not be applicable). OS/400
is one; zOS is another.
Let the world be flat again !

Such research would also demonstrate that filesystems without
hierarchical directories (in the Unix model) need not be flat.

--
Michael Wojcik (e-mail address removed)

Most people believe that anything that is true is true for a reason.
These theorems show that some things are true for no reason at all,
i.e., accidentally, or at random. -- G J Chaitin
 
M

Michael Wojcik

It might be a major product for its vendor, it's still a legacy OS for
those stuck with it.

Mainframes are selling like (expensive) hotcakes, and plenty of their
users are still very happy with them. As a definition of "legacy",
this is pretty useless.
At a previous job, one of the main reasons they
decided to get rid of their large mainframe configuration was precisely
the lack of directory support.

We can play dueling anecdotes all day.

Call them "legacy" if you like, but I'm with Barry on this one. In
any event, there are people writing C programs that have to run on
platforms where there is no hierarchical directory structure such as
the OP's project assumed. Obviously, there are also many C programs
being written that make that assumption and get along fine, since
they never need to run on such a platform.

--
Michael Wojcik (e-mail address removed)

I said, 'I need to put my soul into my work and it is well known that
computers haven't got a soul.' My father said, 'The Americans are working
on it.' -- Sue Townsend, _The Secret Diary of Adrian Mole, Aged 13 3/4_
 
D

Dan Pop

Mainframes are selling like (expensive) hotcakes, and plenty of their
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Any factual evidence for that? From my own experience, their market is
getting narrower and narrower. I've witnessed the phasing out of
mainframes at two sites, but I've never seen a site adopting them as the
right solution for its problems. I've a strong feeling that the new
mainframes sold replace old mainframes rather than increasing the number
of mainframes in current use. Hence the "legacy" thing.
users are still very happy with them.

The users are happy that their legacy applications continue to work.
Few people develop *new* applications for that platform.
As a definition of "legacy", this is pretty useless.

I don't think so. Compare the number of mainframe installations today
with that of 20 - 25 years ago. Ditto about the amount of new software
developed for mainframes. And, finally, try to figure out the health
state of BITNET/EARN today.

Dan
 
D

Dave Thompson

It's hardly a secret. A little research would suffice to identify
operating systems that do not use hierarchical-directory filesystems
(at least for their dominant filesystem), or use something which may
resemble a hierarchical-directory filesystem in some respects but not
in others (so that the OP's project would not be applicable). OS/400
is one; zOS is another.


Such research would also demonstrate that filesystems without
hierarchical directories (in the Unix model) need not be flat.

And to avoid being forgotten, the Guardian personality/mode of
Tandem^WCompaq^WHP NonStop, which is still used and needed for some
new applications because it provides features the POSIX personality
cannot although the overwhelming majority of applications are legacy,
has exactly two levels of directory per disk (or pseudodisk) -- or
actually, two levels of naming in a global directory rather like the
OS/360-et-seq system catalog. Thus you can enumerate files in a
directory -- with a native API, actually two(!) of them, different
from either the Windows or POSIX ones -- and disks (and other devices)
and systems with (sometimes) different API(s) -- but you can never
find or enumerate a (sub)directory in a directory. Of course, if your
code just goes by what you get from the enumeration it is only a waste
of effort but no real harm to handle an impossible case.

- David.Thompson1 at worldnet.att.net
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top