"William A. Rowe, Jr." <[EMAIL PROTECTED]> writes:

> Philip... thanks.
> 
> Now for the oddball question, looking at dirent.h or it's associate sys/ 
> includes, what symbol DT_xxx (DT_REG, etc) do you find for value 0?

/usr/include/dirent.h

/* File types for `d_type'.  */
enum
  {
    DT_UNKNOWN = 0,
# define DT_UNKNOWN     DT_UNKNOWN
    DT_FIFO = 1,
# define DT_FIFO        DT_FIFO
    DT_CHR = 2,
# define DT_CHR         DT_CHR
    DT_DIR = 4,
# define DT_DIR         DT_DIR
    DT_BLK = 6,
# define DT_BLK         DT_BLK
    DT_REG = 8,
# define DT_REG         DT_REG
    DT_LNK = 10,
# define DT_LNK         DT_LNK
    DT_SOCK = 12,
# define DT_SOCK        DT_SOCK
    DT_WHT = 14
# define DT_WHT         DT_WHT
  };

> Also, what values do you have for DIRENT_TYPE, DIRENT_INODE from
> apr/include/arch/unix/apr_private.h?

#define DIRENT_INODE d_fileno
#define DIRENT_TYPE d_type

>From the libc info files:

    `unsigned char d_type'
          This is the type of the file, possibly unknown.  The
          following constants are defined for its value:

         `DT_UNKNOWN'
               The type is unknown.  On some systems this is the only
               value returned.

A test program:

$ cat z.c
#include <dirent.h>
#include <sys/types.h>
int main() {
   DIR *d = opendir(".");
   struct dirent e, *r;
   int v = readdir_r(d, &e, &r);
   while (! v && r) {
      printf("%s %d\n", r->d_name, r->d_type);
      v = readdir_r(d, &e, &r);
   }
   return 0;
}
$ gcc -o z z.c
$ ls -l
total 13
drwxr-sr-x    2 pm       pm             48 Dec 18 18:21 foo
-rwxr-xr-x    1 pm       pm           5147 Dec 18 18:22 z
-rw-r--r--    1 pm       pm            262 Dec 18 18:22 z.c
$ ./z
. 0
.. 0
z 0
foo 0
z.c 0

-- 
Philip Martin

Reply via email to