|
| ffind| Summary | |
#include <rtl.h>
int ffind (
const char *pattern, /* pattern to match files to */
FINFO *info); /* file info structure */
| | Description | | The ffind function searches the Flash File System directory for files matching the specified pattern filter. Matching file information is stored in the info structure. ffind is invoked once for each matching file until a non-zero value is returned. The pattern filter may include an optional drive prefix. If the drive prefix is excluded, ffind uses the default drive specified in the FILE_CONFIG.C configuration file. The following values are supported for the drive prefix: | Drive | Description |
|---|
| "F:" | Embedded Flash drive. | | "S:" | SPI Flash drive. | | "M:" | Memory Card drive. | | "R:" | Ram drive. |
The pattern filter must include a filename pattern to match. Wildcards may be included in the filename. For example: | Pattern | Description |
|---|
"*" "*.*" | Search for all files in the directory. | | "abc*" | Search for files that begin with abc. | | "*.htm" | Search for files that end with .htm. | | "abc*.text" | Search for files that begin with abc and that end with .text. |
The ffind function is in the RL-FlashFS library. The prototype is defined in rtl.h. Note Before invoking the ffind function, you must set the fileID member of the info structure to 0. For example:
.
info.fileID = 0;
while (ffind ("R:*.*",&info) == 0)
.
This member of the info structure is used to identify the first call to ffind. - Flash File System filenames are null-teminated strings.
- The dot character ('.') has no special meaning for the Flash File System. It is not used as a separator for the file name and file type.
| | Return Value | | The ffind function returns a value of 0 to indicate a new file matching the pattern was found. A non-zero return value indicates no matching files were found. If a matching file was found, the info structure is set to the information for the matching file. info contains the: - Filename: The filename is a string limited to a maximum of 32 characters.
- File Size: The file size is the length of the file in bytes.
- File ID: The file ID is a file identification number assigned to a file by the Flash File System.
| | See Also | | ffree | | Example | |
#include <rtl.h>
void file_directory (void) {
FINFO info;
/* 'info.fileID' must initially be set to 0. */
info.fileID = 0;
while (ffind ("R:*.*",&info) == 0) {
printf ("\n%-32s %5d bytes, ID: %04d",
info.name,
info.size,
info.fileID);
}
if (info.fileID == 0) {
printf ("\nNo files...");
}
}
|
|
|