delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2017/01/28/17:13:29

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:mime-version:content-type
:content-transfer-encoding:date:from:to:subject:message-id; q=
dns; s=default; b=sRdfhxBNgroYV3Ni9hLEqK5yR1vtA7Qf69QXWbwHzBekA+
zQtDKlm4waW8KH8KrfQezDkG0Nesq87LYnEM7oe0C2bx//ZmAoEFJ+Qd7UQr7OYi
4qvALzg/IJLNc2GNb6Asr2dguQ4roN/yJ4fdcFMU5mYMJ4hSuAQhByDsXJBNk=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:mime-version:content-type
:content-transfer-encoding:date:from:to:subject:message-id; s=
default; bh=jD/jj+VPvNvJHFMqMe8udtl3lAQ=; b=YWfXOypMLjXCWDHiX4L9
B5ulqYTOI0rlxeIYiRGBfY4G6K4LeVDVF8q75hj8llFL1U0qwIVZlpyb/Wt1URDJ
AVoIAOMU3K/iMQ5gHz4P4SFVGN3xF2zb1H8y0F/OM8xBSgmDf4+ZOiQEDIaPWT9K
7Li1kGL4sBO7STRI42YWphc=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=AWL,BAYES_20,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=erwin, Hx-languages-length:788, UD:xs4all.nl, Erwin
X-HELO: lb1-smtp-cloud2.xs4all.net
MIME-Version: 1.0
Date: Sat, 28 Jan 2017 23:13:03 +0100
From: waterlan <waterlan AT xs4all DOT nl>
To: cygwin AT cygwin DOT com
Subject: dirent.d_type is not working on Cygwin symbolic links.
Message-ID: <b431ce093f2949901c68c3c93fe0693c@xs4all.nl>
X-Sender: waterlan AT xs4all DOT nl
User-Agent: XS4ALL Webmail
X-IsSubscribed: yes

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019