delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/08/02/11:16:40

Date: Sat, 02 Aug 1997 11:13:31 -0400 (EDT)
From: stunajoh AT ACS DOT EKU DOT EDU
Subject: Re: file finding function?
In-reply-to: <33E0581D.4CDBD654@ibogfs.df.unibo.it>
To: Guido Gonzato <guido AT ibogfs DOT df DOT unibo DOT it>
Cc: djgpp AT delorie DOT com
Message-id: <Pine.PMDF.3.95.970802110605.623901D-100000@ACS.EKU.EDU>
MIME-version: 1.0

 

On Thu, 31 Jul 1997, Guido Gonzato wrote:

> Majisun wrote:
> > 
> > Is there a function that will find out if there is any file with a certain
> > extension in the current directory, and then return the filename?
> > 
> >         -Sthel Majisun
> 
> 
> yeah. It's the "file" utility, which can do *much* more than simply look
> for files by extension. Look in the v2gnu/ dir of your simtelnet mirror.
> 
Maybe this is too clumsy for what you want to do, but this would be very
handy if you had more than one file with an extension to find.  

system("dir /b c:\\dir\\*.ext > c:\\filelist.txt");

Then you could read this file back in (c:\filelist.txt).
Also note that you need \\ instad of \ or /, because you are submitting
this to dos.  Also, if that file doesn't exist, there is an error message
that pops up and I don't know how to supress it.
Also, this obviously will only work in Dos.  When opening the files, also
remember to convert the \'s to /'s when using the fstream::open.

- Raw text -


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