[ Not really an internals question, so I'm sending this off to comp.unix.questions. ]In your loolie.
In article <75...@borg.cs.unc.edu> mirc...@schubert.cs.unc.edu (Jaideep Mirchandani) writes:
I am trying to run a program which uses opendir/readdir
to read the entries in a directory. I thought that this would
access the entries in chronological order, so I set the timestamps of
all the files in this directory in the order in which I wanted them read, >by using 'touch'.
Unfortunately, they were not read in time order, so I don't know howreaddir() returns the directory entries in some generally random
to control the program's output. Do you know how I can force opendir/readdir >to read my file entries in a certain order.
order, sort of related to time, but jumbled up as time goes by.
That is, if you start with an empty directory and add files to
it one by one, readdir() might give you the entries back in the
order you entered them. But generally speaking, it doesn't.
What you will probably have to do is set up a structure containing
the appropriate st_?time field and a pointer the file's name. Use
qsort() (or roll your own) and sort the resulting array of file name/timestamp structures.
--
John F. Haugh II | I am the NRA. | UUCP: ...!cs.utexas.edu!rpp386!jfh
Ma Bell: (512) 255-8251 | Shoot a friend today!| Domain: j...@rpp386.cactus.org
" ... expectation is the mother of disappointment."
-- Brad Konopik
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 285 |
Nodes: | 16 (2 / 14) |
Uptime: | 63:48:50 |
Calls: | 6,488 |
Calls today: | 1 |
Files: | 12,096 |
Messages: | 5,274,785 |