Re: [cc65] Common macros for dirent.d_type (was: Need to pass drive number in addition to device number to cbm_opendir)

From: Ullrich von Bassewitz <uz1musoftware.de>
Date: 2012-06-03 19:41:37
On Sun, Jun 03, 2012 at 06:50:30PM +0200, Oliver Schmidt wrote:
> I just noticed that there are now opendir() and friends for the CBM
> machines - thanks :-)

It hasn't much to do with Groepaz' code, which does also mean, it was more
work than expected, and there might be some points that need discussion. But
yes, apart from that, the dirent stuff is now available for the CBMs.

> There is however one small issue that keeps one from cross-target
> directory handling: The readdir() functions tend to return additional
> "things" beside files. On the Apple2 it returns subdirectories and on
> the CBMs it returns the directory header (hope that the correct term).

Currently the disc header is skipped. I don't know if this is a good decision.
This would have been my first question to the CBM guys on the list. It is not
much work to include it in the directory list.

> So I propose to define at least one cross-target macro that contains
> the target-specific value of d_type for an ordinary file. In case
> there's no good definition of the term 'ordinary file' a usable
> definition could probably be an item one can successfully use in
> open() and friends.

It's not as easy for the CBM machines, because there is more than one type of
regular file, and merging this info into one constant will loose information.
So I would suppose test macros, like the ones used for stat():

    if (DT_ISREG (entry->d_type)) {
        /* Regular file */
    } else if (DT_ISDIR (entry->d_type)) {
        /* Directory */
    } else ...

Using test macros would allow to map several CBM file types into the generic
type "regular file". The disadvantage is that they may not be used in a switch
statement or similar.

Regards


        Uz


-- 
Ullrich von Bassewitz                                  uz@musoftware.de
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Sun Jun 3 19:41:46 2012

This archive was generated by hypermail 2.1.8 : 2012-06-03 19:41:49 CEST