filesystems - File type indicator, sys/stat.h st_mode regular file code value -
I am trying to identify file types for directory entries (Windows Unix etc ..).
CIS / State H. Stomoded words are coded values in the High Order NABBB:
#define S_IFDIR 0x4000 / * directory * / #define S_IFIFO 0x1000 / * FIFA special * / #define S_IFCHR 0x2000 / * character special * / # Definitive S_IFBLK 0x3000 / * block special * / #define S_IFREG 0x8000 / * or just 0x0000, Regular * /
The comment can be useful to either 0 or 8 'regular file 'To represent.
Then asks the question: in what circumstances is it not 0 and 8? If I have defined these codes, then I could reserve 0 to suspend some unknown / undefined / invalid / non-one-file or something like that.
Actually the S_ISREG macro is:
#define S_ISREG (m) ((M) and S_IFEG)
This indicates me It seems to be that the regular file will always have code 8 (and 0 will be disturbing?).
Will this be a valid assumption to interpret as an unknown or invalid file and ignore the comment of 'or just 0x0000' and is always expected to use 8 for all regular files?
Most sources indicate that the investigation of S_ISREG is adequate; I'm not sure when you see 0x0000 as a "regular" file
I believe some old implementations use 0x0000 (actually replacing an old DjGPP header service) But this is only an actual reference that I can find. Everything else indicates for 0x8000.
Basically, use the S_ISREG macro and hope that whatever you are compiling, it does the right thing.
Comments
Post a Comment