Re: [AD] how exactly works findfirst

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



On Sun, 28 Jan 2001, ronaldo hideki yamada wrote:

> in
>
>    dta = _al_findfirst(name, attrib, dta_name, &dta_attrib);
>
> how manipulate the field attrib, now the macport ignore this and returns all
> directors and files only attribute returned in dta_attrib is FA_DIREC.
>
> i should return ../ (parent directory) as first match?

No, first return '.' (current dir), then '..' (parent dir) and other
entries (both dirs and files). Of course, don't return '.' and '..' when
you're not asked to return directories. For some kind of example, see
src/libc.c functions _alemu_findfirst() and _alemu_findnext() - those are
functions emulating findfirst/findnext() on POSIX systems (which, IMHO,
MacOS is not - with exception to MacOS X).

In include/allegro/alconfig.h there is:

/* emulate the FA_* flags for platforms that don't already have them */
#ifndef FA_RDONLY
   #define FA_RDONLY       1
   #define FA_HIDDEN       2
   #define FA_SYSTEM       4
   #define FA_LABEL        8
   #define FA_DIREC        16
   #define FA_ARCH         32
#endif

These flags are not stated anywhere in the docs, only at the end of
description of for_each_file():

The file attribute may contain any of the FA_* flags from dir.h.

This is relict from old DOS-Allegro days (as well as
findfirst()/findnext() emulation). Docs should be more specific.

Brief description:

FA_RDONLY
- entries with read only flag (unwritable by current user)

FA_HIDDEN
- hidden entries (hidden under normal circumstances)

FA_SYSTEM
- system file - DOS/WIN relict, don't know if another OS has it

FA_LABEL
- volume label - I'm pretty sure there is no other OS to have this kind of
stupidness
- volume label is present only in root directory on FAT

FA_DIREC
- directory (including special '.' and '..' files)

FA_ARCH
- file marked to archive/archived (I didn't really ever know what is it
exactly)
- DOS/WIN relict, don't know if another OS has it

Have a nice day.

Stepan Roh



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