delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/09/30/00:39:08

From: xenophon AT atl DOT mindspring DOT com (Derek Owens)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: findfirst() findnext() bug?
Date: Mon, 30 Sep 1996 03:49:22 GMT
Organization: MindSpring Enterprises, Inc.
Lines: 28
Message-ID: <52nfcv$155@camel1.mindspring.com>
References: <324F4DE9 DOT 70FC AT stud DOT tue DOT nl>
Reply-To: xenophon AT atl DOT mindspring DOT com
NNTP-Posting-Host: user-168-121-104-192.dialup.mindspring.com
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

"Richard L.F. van Paasen" <R DOT L DOT F DOT v DOT Paasen AT stud DOT tue DOT nl> wrote:
>When I use the findfirst() and findnext() functions of libc,
>the first 2 characters of the names in ffblk.ff_name dissapear.
>Is this a bug in libc.a ? With Borland C, this works fine.

This has been a problem for me, too.  I tried looking in the faq
(both the djgpp faq and the C++ faq) and couldn't find anything
about it.

The following has worked fine for me, though:

   struct _find_t ff;
   // this sets up a pointer to an array of file info
   struct _find_t *F = (struct _find_t *)malloc(sizeof(ff)*numfiles);
   // and the array can be filled with _dos_findfirst and
   // _dos_findnext, and a name can be retrieved like this
   strcpy(Name, F[a].name-2);

The file data is all in there.  For some reason, F[a].name points
to the wrong spot - two bytes after where it should, so simply
subtracting two from it makes it point to the right place.
This looks like it shouldn't work, but it does (at least for
me (for now :) ))

The above code fragments are incomplete.  If you want more detail,
just ask.


- Raw text -


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