| www.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 |
| Date: | Mon, 24 Mar 2003 23:04:30 -0500 (EST) |
| From: | Glenn Fowler <gsf AT research DOT att DOT com> |
| Message-Id: | <200303250404.XAA09833@raptor.research.att.com> |
| Organization: | AT&T Labs Research |
| Mime-Version: | 1.0 |
| References: | <5 DOT 2 DOT 0 DOT 9 DOT 2 DOT 20030324153435 DOT 02db0e68 AT pop3 DOT cris DOT com> |
| To: | cygwin AT cygwin DOT com |
| Subject: | Re: How to decide the file type in Cygwin? |
| Cc: | rrschulz AT cris DOT com |
| X-Spam-Status: | No, hits=-129.3 required=5.0 |
| tests=BAYES_01,EMAIL_ATTRIBUTION,QUOTED_EMAIL_TEXT,REFERENCES, | |
| REPLY_WITH_QUOTES,USER_IN_WHITELIST | |
| autolearn=ham version=2.50 | |
| X-Spam-Level: | |
| X-Spam-Checker-Version: | SpamAssassin 2.50 (1.173-2003-02-20-exp) |
some unix systems { linux bsd uwin } support the
<dirent.h> struct dirent d_type field
the dt_type values { DT_UNKNOWN DT_DIR DT_LNK } can be used to optimize
directory traversals that otherwise would have to stat() directory
entries to discover/count subdirectories
-- Glenn Fowler
On Mon, 24 Mar 2003 15:38:17 -0800 Randall R Schulz wrote:
> Yang,
> Unix file systems don't store the the type of a file system entity in
> the directory entry used to access that entity, they stored in the
> so-called "inode." Once you have a name, use the stat(2) system call to
> get its inode information. From there you'll be able to determine what
> kind of an entity it is. If you have a file descriptor, then fstat(2)
> will do the same.
> Randall Schulz
> At 15:27 2003-03-24, Yang, Huaichen wrote:
> >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:
> >
> >...
> >
> >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 |