mikroSDK Reference Manual
File System Management

File System Management API Reference. More...

Functions list

fs_status_t file_system_format (const char *__generic_ptr path)
 Format the Logical Drive. More...
 
fs_status_t file_system_mount (logical_drive_t *const ldrive_base, const char *__generic_ptr path, physical_drive_t *const pdrive_base)
 Mount Logical Drive to the File System. More...
 
fs_status_t file_system_unmount (const char *__generic_ptr path)
 Unmount Logical Drive from the File System. More...
 
fs_status_t file_system_remove (const char *__generic_ptr path)
 Removes a File or a Directory. More...
 
fs_status_t file_system_rename (const char *__generic_ptr old_path, const char *__generic_ptr new_path)
 Renames a File or a Directory. More...
 
fs_status_t file_system_mkdir (const char *__generic_ptr path)
 Make new Directory. More...
 

Detailed Description

Volume, File and Directory Management and System Configuration.

Function Documentation

◆ file_system_format()

fs_status_t file_system_format ( const char *__generic_ptr  path)

This API function will format the logical drive, identified by its drive number specified in the parameter path. It will use the format function defined in particular files system, in which the logical drive is initialized in, with its default configuration.

Parameters
[in]pathA null terminated string, that specifies the drive number of the logical drive that will be formatted. It should contain the drive number and semicolon at the beginning of the string, eg "3:/". If it does not, the default logical drive, 0:, will be assumed.
Return values
FSS_OKIf the logical drive was formatted successfully,
FSS_GENERAL_ERRORIf the logical drive was not mounted first, if the provided path was wrong, etc.
Precondition
The logical drive must be mounted before this API is called. See file_system_mount for detailed explanation.

◆ file_system_mount()

fs_status_t file_system_mount ( logical_drive_t *const  ldrive_base,
const char *__generic_ptr  path,
physical_drive_t *const  pdrive_base 
)

This API function will mount the logical drive identified by its base ldrive_base, to the file system by registering it with the drive number specified by the parameter path, and then linking it with the physical drive identified by its base pdrive_base. Parts of the structure specific to the particular file system implementation, used by the logical drive will be initialized too.

Parameters
[in]ldrive_baseA pointer to the logical drive base structure. See logical_drive_t, and fatfs_logical_drive_t structures for detailed explanation.
[in]pathA null terminated string, that specifies the drive number that will act as the logical drive identifier by the file system. It should contain the drive number and semicolon at the beginning of the string, eg "3:/". If it does not, the default logical drive, 0:, will be assumed.
[in]pdrive_baseA pointer to physical drive that will be linked with the mounted logical drive. See physical_drive_t, and sdspi_physical_drive_t structures for detailed explanation.
Return values
FSS_OKIf the logical drive was mounted successfully,
FSS_GENERAL_ERRORIf too many drives were mounted already, or if provided drive number in the path parameter already has registered drive with it, etc.
Precondition
ldrive_base and pdrive_base structures must be initialized before calling this function. See fatfs_initialize, and sdspi_physical_drive_init functions for detailed explanation.
Postcondition
Operation on files and directories on the mounted logical drive can now be performed. Other file system APIs can now be called, and to reference the logical drive, drive number specified in path parameter should be used, in their path parameters.
Note
Maximum 5 logical drives can be mounted at the file system at one time. See FS_MAX_VOLUMES.
Both ldrive_base and pdrive_base should be used as bases of derived structures. Eg. fatfs_logical_drive_t, and sdspi_physical_drive_t.

◆ file_system_unmount()

fs_status_t file_system_unmount ( const char *__generic_ptr  path)

This API function will unmount the logical drive, identified by its drive number specified in the path parameter, from the file system, deinitialize its structure, and break the link with its corresponding physical drive. Parts of the structure specific to the particular file system implementation, used by the logical drive will be uninitialized too. If the corresponding physical drive is not linked with any other logical drive, the physical drive structure will also be uninitialized.

Parameters
[in]pathA null terminated string, that specifies the drive number of the logical drive that will be unmounted. It should contain the the logical drive identifying drive number and semicolon at the beginning of the string, eg "3:/". If it does not, the default logical drive, 0:, will be assumed.
Return values
FSS_OKIf the logical drive was unmounted successfully,
FSS_GENERAL_ERRORIf the logical drive was not mounted first, if there are files and directories open on the logical drive, etc.
Precondition
The logical drive must be mounted before this API is called. See file_system_mount for detailed explanation.
Postcondition
Any further usage of unmounted drive structures will require their re-initialization. See fatfs_initialize, and sdspi_physical_drive_init functions for detailed explanation.
Note
Open files or directories on the logical drive identified by the @path should be closed before calling this function.

◆ file_system_remove()

fs_status_t file_system_remove ( const char *__generic_ptr  path)

This function will remove a file or a directory specified by the path parameter, found on the logical drive identified by the drive number specified also in the path parameter.

Parameters
[in]pathA null terminated string, that specifies the absolute path to the file or directory that needs to be removed. It should contain the the logical drive identifying drive number and semicolon at the beginning of the string, eg "3:/". If it does not, the default logical drive, 0:, will be assumed.
Return values
FSS_OKIf a file or a directory was removed successfully,
FSS_GENERAL_ERRORIf the logical drive was not mounted first, if file or directory was not found on the drive, etc.
Warning
File or directory that needs to be removed, must be closed before this function is called.
Precondition
The logical drive must be mounted before this API is called. See file_system_mount for detailed explanation.

◆ file_system_rename()

fs_status_t file_system_rename ( const char *__generic_ptr  old_path,
const char *__generic_ptr  new_path 
)

This function will rename a file or a directory, specified by the old_path parameter, found on the logical drive identified by the drive number specified also in the old_path parameter, with the name specified by the parameter new_path.

Parameters
[in]old_pathA terminated string, that specifies the absolute path to the file or directory that needs to be renamed. It should contain the the logical drive identifying drive number and semicolon at the beginning of the string, eg "3:/". If it does not, the default logical drive, 0:, will be assumed.
[in]new_pathA string that specifies new file or directory name in form of an absolute path. If it contains drive number, it will be ignored.
Return values
FSS_OKIf a file or directory was renamed successfully,
FSS_GENERAL_ERRORIf the logical drive was not mounted first, if file or directory that needs to be renamed was not found on the drive, etc.
Warning
File or directory that needs to be renamed, must be closed before this function is called.
If the absolute path in the function parameters do not match, files or directories that need to be renamed might be moved instead.
Precondition
The logical drive drive must be mounted before this API is called. See file_system_mount for detailed explanation.

◆ file_system_mkdir()

fs_status_t file_system_mkdir ( const char *__generic_ptr  path)

This function will create a new directory with the name and, in the location specified by the path parameter, found on the logical drive identified by the drive number specified also in the path parameter.

Parameters
[in]pathA null terminated string, that specifies the absolute path for directory that needs to be created. It should contain the the logical drive identifying drive number and semicolon at the beginning of the string, eg "3:/". If it does not, the default logical drive, 0:, will be assumed.
Return values
FSS_OKIf the directory was created successfully,
FSS_GENERAL_ERRORIf the logical drive was not mounted first, if the path parameters was wrong, etc.
Precondition
The logical drive drive must be mounted before this API is called. See file_system_mount for detailed explanation.