This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

dirent.d_type is not working on Cygwin symbolic links.


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]