dirent.d_type is not working on Cygwin symbolic links.

waterlan waterlan@xs4all.nl
Sat Jan 28 22:13:00 GMT 2017


Hi,

The dirent.d_type value for Cygwin symbolic links is 0 (DT_UNKNOWN). The 
value is 10 (DT_LNK) for Windows native symbolic links. I think d_type 
should be 10 for Cygwin symbolic links too.


Example program. Run it in a folder with a Cygwin symbolic link and a 
Windows symbolic link (create with mklink command in an administrator 
command prompt).


#include <dirent.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>

int main() {
    DIR *dirp;
    struct dirent *dp;

   dirp = opendir(".");
   dp = readdir(dirp);
   while (dp) {
     printf("%s %d\n", dp->d_name, dp->d_type);

     if (dp->d_type == DT_LNK)
        printf("SYMLINK");

     dp = readdir(dirp);
   }
   closedir(dirp);

   return 0;
}


-- 
Erwin Waterlander
http://waterlan.home.xs4all.nl/

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list