User`s manual

162 digi.com File Systems
2. If you want the next hidden directory:
Start with the FAT_INC_DEF macro default flag. To narrow the search to directories only, we
want entries with their directory attribute set; therefore, OR the macros FATATTR_DIRECTORY
and FAT_FIL_DIR. Then OR the macros FATATTR_HIDDEN and FAT_FIL_HIDDEN to search
only for directories with their hidden attribute set. Set mode to:
FAT_INC_DEF | FATATTR_DIRECTORY | FAT_FIL_DIR | FATATTR_HIDDEN |
FAT_FIL_HIDDEN
3. If you want the next hidden file (no directories):
Start with the predefined flag, FAT_INC_DEF. This flag allows directories, which we do not want, so
we do an AND NOT of the FATATTR_DIRECTORY macro.
Next we want to narrow the search to only entries that have their hidden attribute set. The default flag
does not allow hidden flags, so we need to OR the macros FATTR_HIDDEN and FAT_FIL_HIDDEN.
That is, set mode to:
FAT_INC_DEF & ~FATATTR_DIRECTORY | FATATTR_HIDDEN | FAT_FIL_HIDDEN
4. If you want the next non-hidden file (no directories):
First, select the FAT_INC_DEF filter default flag. This flag allows directories, which we do not want,
so we do an AND NOT of the FATATTR_DIRECTORY macro. The default flag already does not allow
hidden files, so we are done. That is, set mode to:
FAT_INC_DEF & ~FATATTR_DIRECTORY
5. Finally let’s see how to get the next non-empty entry of any type.
Start with the predefined flag, FAT_INC_ALL. This flag selects any directory entry of any type. Since
we do not want empty entries, we have to remove that search condition from the flag, so we do an AND
NOT for the FAT_INC_EMPTY macro to filter out the empty entries. That means mode is the bitwise
combination of the macros:
mode = FAT_INC_ALL & ~FAT_INC_EMPTY
10.2.4.2.6 Deleting Files and Directories
The fat_Delete() function is used to delete a file or directory. The second parameter sets whether a
file or directory is being deleted. Only one file or directory may be deleted at any one time—this means
that you must call fat_Delete() at least twice to delete a file and its associated directory (if the direc-
tory has no other files or subdirectories since a directory must be empty to be deleted).
The first parameter, my_part, points to the static partition structure that was populated by
fat_AutoMount(). The second parameter is the file type, FAT_FILE or FAT_DIR, depending on
whether a file or a directory is to be deleted. The third parameter contains the file name, including the
directory (if applicable) relative to the directory root. All paths in the FAT library are specified relative to
the root directory.
fat_Delete(my_part, FAT_FILE, "DIR/FILE.TXT");