From 7aefd9b4e7b67908b7b3c38b6003c7f1a8d3ee2d Mon Sep 17 00:00:00 2001 From: uz Date: Sun, 24 Jun 2012 14:23:33 +0000 Subject: [PATCH] Added classification macros for file types from struct dirent. git-svn-id: svn://svn.cc65.org/cc65/trunk@5736 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- asminc/cbm_filetype.inc | 25 ++++----- doc/funcref.sgml | 111 ++++++++++++++++++++++++++++++++++++++-- include/cbm_filetype.h | 24 +++++---- include/dirent.h | 10 +++- 4 files changed, 142 insertions(+), 28 deletions(-) diff --git a/asminc/cbm_filetype.inc b/asminc/cbm_filetype.inc index c1f1afcf2..4a4783f92 100644 --- a/asminc/cbm_filetype.inc +++ b/asminc/cbm_filetype.inc @@ -7,21 +7,22 @@ ; Define bitmapped constants for the table entries .enum - CBM_T_DEL ; Deleted file - CBM_T_SEQ ; Sequential file - CBM_T_PRG ; Program file - CBM_T_USR ; User file - CBM_T_REL ; Relative file - CBM_T_CBM ; 1581 sub-partition - CBM_T_DIR ; IDE64 and CMD sub-directory - CBM_T_LNK ; IDE64 soft-link - CBM_T_VRP ; Vorpal fast-loadable format - CBM_T_OTHER ; File-type not recognized - CBM_T_HEADER ; Disk header / title + CBM_T_REG = $10 ; Bit set for regular files + CBM_T_SEQ = $10 ; Sequential file + CBM_T_PRG = $11 ; Program file + CBM_T_USR = $12 ; User file + CBM_T_REL = $13 ; Relative file + CBM_T_DEL = $00 ; Deleted file + CBM_T_CBM = $01 ; 1581 sub-partition + CBM_T_DIR = $02 ; IDE64 and CMD sub-directory + CBM_T_LNK = $03 ; IDE64 soft-link + CBM_T_VRP = $04 ; Vorpal fast-loadable format + CBM_T_OTHER = $05 ; File-type not recognized + CBM_T_HEADER = $06 ; Disk header / title .endenum -; The following function maps the start character for a file type to +; The following function maps the start character for a file type to ; one of the file types above. Note: 'd' will always mapped to CBM_T_DEL. ; The calling function has to look at the following character to determine ; if the file type is actually CBM_T_DIR. diff --git a/doc/funcref.sgml b/doc/funcref.sgml index 6c25c1018..cea56de37 100644 --- a/doc/funcref.sgml +++ b/doc/funcref.sgml @@ -279,7 +279,11 @@ Low-level disk I/O API.

- + + + + + @@ -714,6 +718,105 @@ communication. Alphabetical function reference

+_DE_ISDIR

+ + + +/ + +The function is actually a macro. + +, +, + + + + + +_DE_ISLBL

+ + + +/ + +The function is actually a macro. + +, +, + + + + + +_DE_ISLNK

+ + + +/ + +The function is actually a macro. + +, +, + + + + + +_DE_ISREG

+ + + +/ + +The function is actually a macro. +A "regular file" means anything with data in it. This might still mean +that special processing is needed, when accessing the file. Relative files of +the CBM systems are classified as being "regular" files, for example. + +, +, + + + + + _heapadd

@@ -1668,7 +1771,7 @@ be used in presence of a prototype. / The function is only available as fastcall function, so it may only @@ -4217,9 +4320,9 @@ had been used with an argument of 1. / The function is only available as fastcall function, so it may only diff --git a/include/cbm_filetype.h b/include/cbm_filetype.h index 9192ee3e9..f4807edf6 100644 --- a/include/cbm_filetype.h +++ b/include/cbm_filetype.h @@ -53,18 +53,20 @@ /* CBM FILE TYPES. The definitions are used within standard headers, so we * be careful with identifiers in the user name space. + * "Regular" files have a special bit set so it's easier to pick them out. */ -#define _CBM_T_DEL 0 -#define _CBM_T_SEQ 1 -#define _CBM_T_PRG 2 -#define _CBM_T_USR 3 -#define _CBM_T_REL 4 -#define _CBM_T_CBM 5 /* 1581 sub-partition */ -#define _CBM_T_DIR 6 /* IDE64 and CMD sub-directory */ -#define _CBM_T_LNK 7 /* IDE64 soft-link */ -#define _CBM_T_VRP 8 /* Vorpal fast-loadable format */ -#define _CBM_T_OTHER 9 /* File-type not recognized */ -#define _CBM_T_HEADER 10 /* Disk header / title */ +#define _CBM_T_REG 0x10U /* Bit set for regular files */ +#define _CBM_T_SEQ 0x10U +#define _CBM_T_PRG 0x11U +#define _CBM_T_USR 0x12U +#define _CBM_T_REL 0x13U +#define _CBM_T_DEL 0x00U +#define _CBM_T_CBM 0x01U /* 1581 sub-partition */ +#define _CBM_T_DIR 0x02U /* IDE64 and CMD sub-directory */ +#define _CBM_T_LNK 0x03U /* IDE64 soft-link */ +#define _CBM_T_VRP 0x04U /* Vorpal fast-loadable format */ +#define _CBM_T_OTHER 0x05U /* File-type not recognized */ +#define _CBM_T_HEADER 0x06U /* Disk header / title */ #if __CC65_STD__ == __CC65_STD_CC65__ /* Allow for names without leading underscores */ diff --git a/include/dirent.h b/include/dirent.h index cb3ddc139..63a96ea82 100644 --- a/include/dirent.h +++ b/include/dirent.h @@ -85,12 +85,20 @@ struct dirent { char d_name[16+1]; unsigned int d_off; unsigned int d_blocks; - unsigned char d_type; /* See CBM_T_xxx defines in cbm.h */ + unsigned char d_type; /* See _CBM_T_xxx defines */ /* bsd extensions */ unsigned char d_namlen; }; +/* File type specification macros. We need definitions of CBM file types. */ +#include + +#define _DE_ISREG(t) (((t) & _CBM_T_REG) != 0) +#define _DE_ISDIR(t) ((t) == _CBM_T_DIR) +#define _DE_ISLBL(t) ((t) == _CBM_T_HDR) +#define _DE_ISLNK(t) ((t) == _CBM_T_LNK) + #elif defined(__LYNX__) struct dirent { -- 2.39.5