• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
dirent->d_type: DT_LNK oddness ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

dirent->d_type: DT_LNK oddness ?


  • Subject: dirent->d_type: DT_LNK oddness ?
  • From: "David Carpeneto" <email@hidden>
  • Date: Tue, 25 Apr 2006 13:11:09 -0400
  • Thread-topic: dirent->d_type: DT_LNK oddness ?

Hiya -

Playing with BSD File routines & it seems that *every* file I retrieve
info on via readdir that isn't a directory or a pipe/fifo has "DT_LNK"
set.

I would have thought that this should only be set for symbolic links
(cannot be sure, since sys/dirent.h doesn't elaborate on the enums
listed, and I can find nothing on this via google.

Should I maybe be using something other than readdir to grab the
contents of a directory ? At this point I'm looking for file name, and
the type of stuff that (I thought) was included in dirent's d_type
(whether something is a directory, pipe, link or 'regular' file).

FWIW, here's a snipped of code that illustrates what I'm doing:

#include <stdio.h>
#include <sys/types.h>
#include <sys/dir.h>

int main(int argc, char *argv[]) {

        DIR *dirp;
        struct dirent *dp;

        dirp = opendir(argv[1]);
        while ((dp = readdir(dirp)) != NULL) {
                printf("NAME IS : %s", dp->d_name);
                if (dp->d_type & DT_UNKNOWN) printf("\t\tUNKNOWN");
                if (dp->d_type & DT_DIR)     printf("\t\tDIRECTORY");
                if (dp->d_type & DT_LNK)     printf("\t\tLINK");
                if (dp->d_type & DT_FIFO)     printf("\t\tPIPE");
                printf("\n");
        }
        (void)closedir(dirp);

    return 0;
} // fin

Thanks for any advice you can throw at me - Dave
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: dirent->d_type: DT_LNK oddness ?
      • From: Mike Mackovitch <email@hidden>
  • Prev by Date: Re: Launchd and domain sockets, accept() problem (was Re: launchd APIs)
  • Next by Date: RE: dirent->d_type: DT_LNK oddness ?
  • Previous by thread: Re: lsof befuddled on 10.4.6?
  • Next by thread: Re: dirent->d_type: DT_LNK oddness ?
  • Index(es):
    • Date
    • Thread