www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/03/06/08:36:37.2

From: Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: directory&files
Date: 6 Mar 2001 13:34:22 GMT
Organization: Aachen University of Technology (RWTH)
Lines: 22
Message-ID: <982p0u$mks$1@nets3.rz.RWTH-Aachen.DE>
References: <980qkc$lj0$1 AT pegasus DOT tiscalinet DOT it>
NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de
X-Trace: nets3.rz.RWTH-Aachen.DE 983885662 23196 137.226.32.75 (6 Mar 2001 13:34:22 GMT)
X-Complaints-To: abuse AT rwth-aachen DOT de
NNTP-Posting-Date: 6 Mar 2001 13:34:22 GMT
Originator: broeker@
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Abacuc <f DOT onorati AT tiscalinet DOT it> wrote:
> How can i distinguish a file or a directory? 

Within the DJGPP framework, stat() and fstat() are the proper answer.

For an "extremely portable" program, you cannot do this at all, since
the ANSI C standard doesn't even assume there is any such thing as a
"directory". To it, a filename is an opaque entity without further
structure inside. Only in the realm of other, less widely applicable
standards, like POSIX, you have functions like opendir()/readdir() to
work with directories.

> And how can I know the extensions of the files (exe, com, jpg,
> etc.)? 

That's simple: use strcmp() or strstr() to search for them in the
filenames, once you have them.


-- 
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.

- Raw text -


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