File System Component
Version 6.6
MDK-Professional Middleware for Devices with Flash File System
|
File maintenance routines perform file management operations. More...
Functions | |
fsStatus | fdelete (const char *path, const char *options) |
Delete one or multiple files. | |
fsStatus | ffind (const char *pattern, fsFileInfo *info) |
Find a file or directory matching search pattern. | |
fsStatus | frename (const char *path, const char *newname) |
Rename a file or directory with given path name to a new name. | |
fsStatus | fattrib (const char *path, const char *attr) |
Change file attributes. | |
The routines are thread safe.
fsStatus fattrib | ( | const char * | path, |
const char * | attr | ||
) |
[in] | path | string specifying file or directory path. |
[in] | attr | string specifying file or directory attributes to be modified. The following characters are allowed within attr string:
|
The function fattrib changes file or directory attributes. File specified by the path argument shall not have any active file handle, otherwise the delete will fail and fsAccessDenied status code will be returned.
The path argument is specifying the file or directory path. If the drive prefix is omitted, the Current Drive is used.
The argument attr is specifying file or directory attributes to be modified. The following characters are allowed within par string:
Character | Function |
---|---|
+ | Sets an attribute |
- | Clears an attribute |
R | Read-only file attribute |
A | Archive file attribute |
S | System file attribute |
H | Hidden file attribute |
Code Example
fsStatus fdelete | ( | const char * | path, |
const char * | options | ||
) |
[in] | path | a string specifying the file or directory. |
[in] | options | a string specifying function options. |
The function fdelete deletes one or more files. If path argument points to the existing file, it is removed. If path argument points to the directory, all files within that directory are removed. File(s) specified by the path argument shall not have any active file handle, otherwise the delete will fail and fsAccessDenied status code will be returned.
The path argument is specifying the file or directory path. If the drive prefix is omitted, the Current Drive is used.
The options argument can be NULL when options are not used or a pointer to a string specifying following options:
Option | Description |
---|---|
/S | Remove all files within specified directory and all subdirectories. |
Code Example
fsStatus ffind | ( | const char * | pattern, |
fsFileInfo * | info | ||
) |
[in] | pattern | string specifying the pattern.
|
[out] | info | structure storing information about matching files. |
The function ffind searches for files or directories that match specific pattern. It can be used for explicit search, when full path is specified or iterative search, when using wildcard character within path.
The argument pattern is specifying the file or directory path. If the drive prefix is omitted, the Current Drive is used. Wildcard character * can be used when searching for multiple files. The following search rules apply:
Pattern | Description |
---|---|
"*" or "*.*" | Searches for all files in the directory |
"abc*" | Searches for files that begin with abc |
"*.htm" | Searches for files that end with .htm |
"abc*.text" | Searches for files that begin with abc and end with .text |
When file or directory matching specified pattern is found, fsOK status code is returned and its name, size, attributes and time stamps are returned to the info structure. Status code fsFileNotFound is returned when function fails to find any file or directory that matches to specified pattern.
Member fileID of the fsFileInfo structure is used to control the file search and must be set to 0 (zero) before starting a new search. When performing iterative search, function must be called repeatedly and in that case fileID shall not be changed until the search ends.
Code Example
fsStatus frename | ( | const char * | path, |
const char * | newname | ||
) |
[in] | path | string specifying the file or directory path. |
[in] | newname | string specifying new file or directory name. |
The function frename replaces the name of a file or directory. File specified by the path argument shall not have any active file handle, otherwise the rename will fail and fsAccessDenied status code will be returned.
The path argument is specifying the current name of the file or directory. If the drive prefix is omitted, the Current Drive is used.
The argument newname is specifying the new name of the file or directory.
Code Example