[AD] About findfirst (2)

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Summary of the problem: the Allegro docs (section "Files and compression
routines") state that "If your platform doesn't have the find* set of
functions, Allegro will emulate them." They are relating to the DOS
findfirst(), findnext() and findclose() functions. After some discussion on
[AD] (and what seems to be an U-turn by one of the participant ;-), we
agreed about the usefulness of the the functions, hence to make them
available on every platform supported by Allegro.

Here's the current status:
- DOS: native support
- Unixes: emulation (on top of POSIX, src/libc.c)
- BeOS: emulation (on top of POSIX, src/libc.c)
- QNX: emulation (on top of POSIX, src/libc.c)
- Windows: no support
- MacOS: no support

Moreover, I pointed out that every port already provides three internal
functions _al_findfirst(), _al_findnext() and _al_findclose() as an
interface to src/file.c, however with a somewhat different semantics from
that of the DOS find* functions. Therefore it seems to be sensible to reuse
this already existing code.

The proposal: we should provide the functionalities of the find* set of
functions by exposing the three internal functions, after revamping their
interface to let it match that of the DOS functions. More precisely:

   struct al_ffblk
   {
      unsigned char ff_attrib;
      unsigned short ff_ftime;
      unsigned short ff_fdate;
      unsigned long ff_fsize;
      char ff_name[1024];
      void *ff_info;
   };

   int al_findfirst(AL_CONST char *pattern, struct al_ffblk *ffblk,
                         int attrib);
   int al_findnext(struct ffblk *al_ffblk);
   void al_findclose(struct ffblk *al_ffblk);

Needed changes:
- moving the POSIX emulation from src/libc.c to src/misc/ufile.c,
- src/dos/dfile.c: new interface,
- src/misc/ufile.c: new interface,
- src/win/wfile.c: new interface + translation of the Windows _find*(),
- src/mac/mfile.c: new interface + some implementation work,
- src/file.c: some minor modifications.

I'm ok to do the work minus the MacOS stuff, while Ronaldo is ok to make the
necessary modifications to the MacOS port.
What do you think about that ?

---
Eric Botcazou
ebotcazou@xxxxxxxxxx



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/