fpreaddir
-> http://www.freepascal.org/docs-html/rtl/baseunix/fpreaddir.html
dirent record structure
-> http://www.freepascal.org/docs-html/rtl/baseunix/dirent.html
How do I know if the readed entry is a subdir?
Rainer

Mailing lists / fpc-pascal / 2008-05
6 messages · 3 people ·
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
fpreaddir
-> http://www.freepascal.org/docs-html/rtl/baseunix/fpreaddir.html
dirent record structure
-> http://www.freepascal.org/docs-html/rtl/baseunix/dirent.html
How do I know if the readed entry is a subdir?
Rainer
d_type being DT_UNKNOWN 0 DT_FIFO 1 DT_CHR 2 DT_DIR 4…
The result of d_type is always 0 even if the entry is a directory.
Your question is not easy to answer.
In one way you are right, but I like to program as close to the os as possible.
Does findfirst/findnext also support these things like '*.pas' and file attributes?
fpreaddir -> http://www.freepascal.org/docs-html/rtl/baseunix/fpreaddir.html dirent…
d_type being
DT_UNKNOWN 0
DT_FIFO 1
DT_CHR 2
DT_DIR 4
DT_BLK 6
DT_REG 8
DT_LNK 10
DT_SOCK 12
DT_WHT 14
But why do you not simply use findfirst/findnext? It's more portable.
The result of d_type is always 0 even if the entry is a directory. Your question is not…
Then you'll have to do a fpstat to get additional data.
Your question is not easy to answer. In one way you are right, but I like to program as close to the os as possible.
In general findfirst/findnext is ok, unless you are creating e.g. an unix specific backup application that touches hundreds of thousands of files.
Does findfirst/findnext also support these things like '*.pas' and file attributes?
It supports wildcards. The file attributes are limited to the ones in searchrec, see help for more info.
What os are you on? I did "man readdir" and "man dirent" and found enough information. One
Marc Santhoff wroteWhat os are you on?
Knoppix last DVD from heise
I did "man readdir" and "man dirent" and found enough information. One bit from the dirent manpage:
I did it also
...
Other than Linux, the d_type field is available mainly only on BSD systems. This field makes it possible to avoid the expense of calling stat() if further actions depend on the type of the file. ...
So I will use stat.
The result of d_type is always 0 even if the entry is a directory. Your question is not…
What os are you on?
I did "man readdir" and "man dirent" and found enough information. One bit from the dirent manpage:
BUGS
The usage of the member d_type of struct dirent is unportable as it is FreeBSD-specific. It also may fail on certain filesystems, for example the cd9660 filesystem.
Maybe that's hitting you ...
HTH,
Marc