File and Directory Attributes
The FSEntry_Query() function gets information about file system entry, including its attributes, which indicate whether it is a file or directory, writable or read-only, and visible or hidden (see Listing - Example FSEntry_Query() usage).
Listing - Example FSEntry_Query() usage
FS_FLAGS attrib;
FS_ENTRY_INFO info;
FSEntry_Query("path_name", /* pointer to full path name */
&info, /* pointer to info */
&err); /* return error */
attrib = info.Attrib;The return value is a logical OR of attribute flags:
FS_ENTRY_ATTRIB_RD
Entry is readable.
FS_ENTRY_ATTRIB_WR
Entry is writable.
FS_ENTRY_ATTRIB_HIDDEN
Entry is hidden from user-level processes.
FS_ENTRY_ATTRIB_DIR
Entry is a directory.
FS_ENTRY_ATTRIB_ROOT_DIR
Entry is a root directory.
If no error is returned and FS_ENTRY_ATTRIB_DIR is not set, then the entry is a file.
An entry can be made read-only (or writable) or hidden (or visible) by setting its attributes:
The second argument should be the logical OR of relevant attribute flags.
attrib = FS_ENTRY_ATTRIB_RD;
FSEntry_AttribSet("path_name", /* pointer to full path name */
attrib, /* attributes */
&err); /* return error */
FS_ENTRY_ATTRIB_RD
Entry is readable.
FS_ENTRY_ATTRIB_WR
Entry is writable.
FS_ENTRY_ATTRIB_HIDDEN
Entry is hidden from user-level processes.
If a flag is clear (not OR’d in), then that attribute will be clear. In the example above, the entry will be made read-only (i.e., not writable) and will be visible (i.e., not hidden) since the WR and HIDDEN flags are not set in attrib. Since there is no way to make files write-only (i.e., not readable), the RD flag should always be set.