www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/07/25/12:01:49

From: xmerm05 AT vse DOT cz (Mertl Michal - UC,,student,UID=22797)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Need help with findfirst(..) (not the "two characters lost" progblem...)
Date: Fri, 25 Jul 1997 08:57:11 GMT
Organization: University of Economy, Prague
Lines: 38
Message-ID: <xmerm05.1.33D86A67@vse.cz>
References: <01bc978a$dd9f0ac0$6793f482 AT marcus>
NNTP-Posting-Host: j357h17.vse.cz
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Marcus Persson wrote:
>I can't get findfirst to search for files through the sub directories (with
>FA_DIREC)...
>Plese help me... I'm using Win 95 / DOS 7.0 and DJGPP v 2.10

> struct ffblk file_inf;
> int done;
> printf("File(s) found:\n");
> done = findfirst ("*.txt",&file_inf,FA_DIREC);

You probably understand the behaviour if findfirst and findnext totally 
wrong. So as name says find first finds the first file in the specified 
directory (as a first parameter you can have "c:\foo\*.txt") matching the 
specified file extension and having possibly set the attributes like 
FA_DIREC, FA_ARCHIVE (not sure about the name) (you won't see files such are 
readonly without FA_RDONLY). Then you just call findnext until you get error 
(no next file) receiving next files. It _never_ goes to subdirectories.
Note that you also don't print anything except "File(s) found:\n". And 
FA_DIREC in attribute field means that it finds also directories *.txt.

So your code should probably continue with:
printf("%s\n",file_inf.name(?));
while (done!=err) { /*(Don't know the result code meaning an error occured*/
  done=findnext(&file_inf);     
  printf("%s\n",fild_inf.name(?));
}

I know it works this way but am not sure without docs with exact names...
Sorry about that.

Michal

    //\\  //\\     ..
   //  \\//  \\
  //    \/    \\   || |/\/\  /---\
 //            \\  || | | |  |___'
//              \\ || | | |  \___.
        E-Mail: MiMe AT EUnet DOT cz

- Raw text -


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