delorie.com/archives/browse.cgi | search |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
List-Archive: | <http://sources.redhat.com/ml/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/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 |
Message-ID: | <973C11FE0E3ED41183B200508BC7774C0C95EB49@csexchange.crystal.cirrus.com> |
From: | "Yang, Huaichen" <huaichen DOT yang AT cirrus DOT com> |
To: | "'cygwin'" <cygwin AT cygwin DOT com> |
Subject: | How to decide the file type in Cygwin? |
Date: | Mon, 24 Mar 2003 17:27:38 -0600 |
MIME-Version: | 1.0 |
I need to list all files in a folder (including sub-folder, recursively), and I tried some sample codes in GNU C manual, as follows: /***********************/ #include <stddef.h> #include <stdio.h> #include <sys/types.h> #include <dirent.h> int main (void) { DIR *dp; struct dirent *ep; dp = opendir ("./"); if (dp != NULL) { while (ep = readdir (dp)) puts (ep->d_name); (void) closedir (dp); } else puts ("Couldn't open the directory."); return 0; } /***********************/ The sample was working. Then I added some codes to check the ep->d_type (the type of the file). If it was a directory, the program would check the sub-folder recursively. However, I encountered a compiler error. The property d_type was not defined in the Cygwin header file dirent.h. It seems that we cannot distinguish the files from the directories. Is that true? Doesn't anybody have a good idea to do this? Thank you very much in adavance! -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |