delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/10/31/11:55:33

From: kagel AT quasar DOT bloomberg DOT com
Date: Thu, 31 Oct 1996 11:30:51 -0500
Message-Id: <9610311630.AA05305@quasar.bloomberg.com >
To: kolodzie AT sabat DOT tu DOT kielce DOT pl
Cc: djgpp AT delorie DOT com
In-Reply-To: <3278F567.1D80@sabat.tu.kielce.pl> (message from Grzegorz Kolodziej on Thu, 31 Oct 1996 13:52:23 -0500)
Subject: Re: Problem with findfirst & findnext
Reply-To: kagel AT dg1 DOT bloomberg DOT com

   Errors-To: postmaster AT bloomberg DOT com
   Organization: Technical University of Kielce
   Address: Al. Tysiaclecia P.P. 7, 25-314 Kielce, POLAND
   Date: Thu, 31 Oct 1996 13:52:23 -0500
   From: Grzegorz Kolodziej <kolodzie AT sabat DOT tu DOT kielce DOT pl>
   X-Mailer: Mozilla 2.02 (Win16; I)
   Mime-Version: 1.0
   X-Url: ftp://netcom.com/pub/el/elf/rcsdos
   Content-Transfer-Encoding: 7bit
   Content-Type: text/plain; charset=iso-8859-2
   Content-Length: 781

   I needed some code to erase work files of my application, the solution
   was obvious - only at first sigth :-)

	  ....
   int res;
   struct ffblk FB;
	  ....
   res=findfirst("*.bin",&FB,FA_ARCH);
   while(!res){ unlink(FB.ff_name);
		res=findnext(&FB); 
	       }
	  ....

   but it doesn't work ...

   The problem is (as it can be seen using gdb):
   While findfirst() finds file (res==0) the ffblk structure contains
   strange values i.e. field ff_name contains file name without first 
   2 letters,ff_fsize is any huge number (other fields aren't correct 
   also), so found file  couldn't be deleted by unlink().

   I used DJGPP ver. 2.0 on MSDOS 6.20. The same piece of code works
   fine if compiled with TC.

   What's wrong? Who has any idea? Maybe this problem isn't new - if
   so - forgive me.

This was a GCC C++ bug related to structure packing not working properly.
I believe that this was fixed in the recently released 2.01 DJGPP release.
For the short term edit the include file that findfirst/findnext uses and
change the way that the structure is packed or compile the function as a 
"C" function and import it into your C++ program.

-- 
Art S. Kagel, kagel AT quasar DOT bloomberg DOT com

A proverb is no proverb to you 'till life has illustrated it.  -- John Keats

- Raw text -


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