Mail Archives: djgpp/1997/08/02/11:16:40
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 -