Re: General C question - file attributes [offtopic]
- From: Jan Kratochvil <short ucw cz>
- To: gtk-list redhat com
- Cc: Travis Loyd <lelandg usa net>
- Subject: Re: General C question - file attributes [offtopic]
- Date: Sun, 15 Aug 1999 18:38:08 +0200
> On Sun, Aug 15, 1999 at 09:25:55AM -0400, John C Atkeson wrote:
> > I'm reading directories with opendir, readdir and closedir. Um... how
> I was looking for these... glad I read your question.
> > do I detect file attributes, specifically how to distinguish files from
> > sub-directories?
> In the man page for readdir I found this:
> struct dirent {
> long d_ino; /* inode number */
> off_t d_off; /* offset to the next dirent */
> unsigned short d_reclen;/* length of this record */
> unsigned char d_type; /* type of file */
> char d_name[256]; /* filename */
> };
> That is what is returned from readdir, this is just a guess but I would think
> that d_type is what you are looking for.
Beware - I have very bad experience with "d_type" field. Although it is
present, it's value is often (always?) bogus. Check stat(2) call and "st_mode"
field of the resulting "struct stat" to get reliable result across unices.
> Travis Loyd <lelandg@usa.net>
Lace
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]