×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Oct 2010
    Posts
    10

    struct dirent, file type problem

    Hi all,

    I am using this code to list a directory:
    DIR *dir;
    struct dirent *dirent = 0;
    if((dir = opendir("c:\\DATA")) != 0)
    {
    while ((dirent = readdir(store->dir)) != 0)
    {
    if( dirent->d_type == DT_REG )
    {
    // do something
    }
    dirent = 0;
    }
    }

    But the d_type of dirent is always DT_UNKNOWN... why is that ?
    for info, the files in the directory have been created with
    int fd = open("myfile",O_WRONLY|O_CREAT|O_BINARY|O_TRUNC, 0700) and close(fd) has been called before I list the directory.

    I can of course check for DT_UNKNOWN instead of DT_REG, but I'd like to know if i am missing something or if there is a reason why I get DT_UNKNOWN.

    I am porting from windows... where it return DT_REG...

    Thanks !
    Last edited by cglolo; 2010-11-24 at 04:14.

  2. #2
    Registered User
    Join Date
    Dec 2006
    Posts
    2,280

    Re: struct dirent, file type problem

    Read: http://www.gnu.org/s/libc/manual/htm...y-Entries.html
    This is valid behaviour - the implementation doesn't have to differentiate between regular files and directories for you in this API. Apparently Symbian doesn't.

Similar Threads

  1. How to read STRUCT from .rsc file
    By BabyKiller in forum Symbian
    Replies: 4
    Last Post: 2009-07-24, 08:13
  2. Problem with append an struct to array
    By masoud_bayat in forum Symbian
    Replies: 10
    Last Post: 2008-10-21, 15:56
  3. stat(char*, struct stat) problem
    By strike_noir in forum Open C/C++
    Replies: 2
    Last Post: 2008-07-03, 04:57
  4. Replies: 0
    Last Post: 2006-02-24, 02:09
  5. Replies: 0
    Last Post: 2006-02-23, 07:57

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×