# /etc/rawhide.conf.d/attributes (macOS)
# See rh(1) and rawhide.conf(5) for more information.

/*
This file defines aliases for the built-in symbols for macOS file
flags, and the related constants and predicates. See <sys/stat.h>.
*/

// Aliases for the macOS file flags built-ins

flag       { attr }
flags      { attr }
attrs      { attr }
attribute  { attr }
attributes { attr }
project    { 0 }
generation { 0 }

// Flag constants from <sys/stat.h>

# Super-user and owner changeable flags

UF_SETTABLE   { 0x0000ffff } # mask of owner changeable flags
UF_NODUMP     { 0x00000001 } # do not dump file
UF_IMMUTABLE  { 0x00000002 } # file may not be changed
UF_APPEND     { 0x00000004 } # writes to file may only append
UF_OPAQUE     { 0x00000008 } # directory is opaque wrt. union

UF_COMPRESSED { 0x00000020 } # file is compressed (some file-systems)
UF_TRACKED    { 0x00000040 } # notifications no longer issued
UF_DATAVAULT  { 0x00000080 } # entitlement required for reading and writing
UF_HIDDEN     { 0x00008000 } # hint that this item should not be displayed in a GUI

# Super-user changeable flags

SF_SUPPORTED  { 0x009f0000 } # mask of superuser supported flags
SF_SETTABLE   { 0x3fff0000 } # mask of superuser changeable flags
SF_SYNTHETIC  { 0xc0000000 } # mask of system read-only synthetic flags */
SF_ARCHIVED   { 0x00010000 } # file is archived
SF_IMMUTABLE  { 0x00020000 } # file may not be changed
SF_APPEND     { 0x00040000 } # writes to file may only append
SF_RESTRICTED { 0x00080000 } # entitlement required for writing */
SF_NOUNLINK   { 0x00100000 } # Item may not be removed, renamed or mounted on */
SF_FIRMLINK   { 0x00800000 } # file is a firmlink
SF_DATALESS   { 0x40000000 } # file is dataless object

// Flag predicates (canonical, aliases)

arch       { attr & SF_ARCHIVED }
archived   { attr & SF_ARCHIVED }
nodump     { attr & UF_NODUMP }
opaque     { attr & UF_OPAQUE }
compressed { attr & UF_COMPRESSED }
tracked    { attr & UF_TRACKED }
datavault  { attr & UF_DATAVAULT }
hidden     { attr & UF_HIDDEN }
sappnd     { attr & SF_APPEND }
sappend    { attr & SF_APPEND }
schg       { attr & UF_IMMUTABLE }
schange    { attr & UF_IMMUTABLE }
simmutable { attr & UF_IMMUTABLE }
uappnd     { attr & UF_APPEND }
uappend    { attr & UF_APPEND }
uchg       { attr & SF_IMMUTABLE }
uchange    { attr & SF_IMMUTABLE }
uimmutable { attr & SF_IMMUTABLE }
restricted { attr & SF_RESTRICTED }
nounlink   { attr & SF_NOUNLINK }
unlink     { attr & SF_NOUNLINK }
firmlink   { attr & SF_FIRMLINK }
dataless   { attr & SF_DATALESS }

append    { uappend    | sappend }
immutable { uimmutable | simmutable }

