Mail Archives: djgpp/1996/10/31/11:55:33
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 -