Thread: dirent.h d_type

  1. #1
    Registered User -world's Avatar
    Join Date
    Jul 2010
    Posts
    4

    dirent.h d_type

    I suppose this is more of a UNIX question than a Linux question, but I'm not sure where else to post it.

    I'm using the struct dirent (dirent.h) member d_type on an application I'm building, but I need to port it to a UNIX platform, and apparently d_type is only available in the GNU libraries. Does anyone know of an UNIX alternative I could use, or some methodology I could use to figure out if a an entry in a directory is a directory or file?

    I thought about maybe reading inode entries, but I'm not sure how to do that.

    Thanks for all your help!

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    The stat() function tells you all about a particular file.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User -world's Avatar
    Join Date
    Jul 2010
    Posts
    4
    Hey, thanks for your help! Switching from d_type to the functionality in stat.h worked to build the program. Now I'm running into a different problem... but I'll try to hunt down the answer first. =)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Using pcap, dirent.h and error C2085, C2061
    By hjazz in forum C Programming
    Replies: 1
    Last Post: 11-23-2009, 12:59 PM
  2. concatentating dirent.h dname from dirent.h to the path in C
    By amjadcsu in forum Linux Programming
    Replies: 1
    Last Post: 07-20-2009, 04:55 PM
  3. How to use this part of dirent.h
    By kermit in forum Linux Programming
    Replies: 2
    Last Post: 01-31-2009, 08:51 AM
  4. Directories and files using dirent.h
    By totalnewbie in forum C Programming
    Replies: 6
    Last Post: 11-19-2008, 05:10 PM
  5. dirent.h d_name
    By srm2888 in forum C Programming
    Replies: 1
    Last Post: 03-03-2008, 09:12 AM