mikroSDK Reference Manual
Directory Access

Directory Access and Management. More...

Modules

 Directory Data
 Directory Data Structure Reference.
 

Functions list

fs_status_t dir_open (dir_t *dir, fs_dir_t fs_specific_dir, const char *__generic_ptr path)
 Open a Directory. More...
 
fs_status_t dir_close (dir_t *dir)
 Close an Opened Directory. More...
 
fs_status_t dir_read (dir_t *dir, void *file_information)
 Read Directory Entry. More...
 
fs_status_t dir_rewind (dir_t *dir)
 Move Read/Write Offset to the beginning of the Directory. More...
 

Detailed Description

Function Documentation

◆ dir_open()

fs_status_t dir_open ( dir_t dir,
fs_dir_t  fs_specific_dir,
const char *__generic_ptr  path 
)

This API function will open an existing dir in a location specified by the parameter path, on the logical drive identified by the drive number found also in the path parameter. The directory data structure specific to the particular file system implementation fs_specific_dir, and dir structure will be initialized too.

Parameters
[in,out]dirA pointer to the directory data structure, that acts as the directory identifier. See dir_t, structure for detailed explanation.
[in]fs_specific_dirA pointer to the directory data structure specific to the particular file system. See fs_dir_t structure for detailed explanation.
[in]pathA null terminated string, that specifies the absolute path to the directory that needs to be opened. 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 opened successfully,
FSS_GENERAL_ERRORIf too many directories or files are opened already, if directory identified by the dir paramater does not exist on the logical drive identified by the parameter path, etc.
Precondition
A logical drive must be mounted to the file system to the location specified by the path See file_system_mount function for detailed explanation.
Postcondition
Other directory access APIs can now be called, using the dir structure as identifier, allowing various operations with the opened directory.
Note
Maximum 10 files and/or directories can be opened at one time. See FS_MAX_OBJECTS.

◆ dir_close()

fs_status_t dir_close ( dir_t dir)

This API function will close an open dir object.

Parameters
[in,out]dirA pointer to the directory data structure, that acts as the opened directory identifier. See dir_t, structure for detailed explanation.
Return values
FSS_OKIf the directory was closed successfully,
FSS_GENERAL_ERRORIf the dir was not opened, or if there was an error on the physical drive linked to the logical drive, etc.
Precondition
The dir must be opened first, before calling this function. See dir_open, function for detailed explanation.

◆ dir_read()

fs_status_t dir_read ( dir_t dir,
void *  file_information 
)

This API function will read an directory entry, from the opened dir.

Parameters
[in]dirA pointer to the directory data structure, that acts as the opened directory identifier. See dir_t, structure for detailed explanation.
[in]file_informationA pointer to the structure, where the read directory entry will be stored.
Return values
FSS_OKIf the directory entry was read successfully.
FSS_END_OF_DIRECTORYIf read directory was null .
FSS_GENERAL_ERRORIf the dir was not opened, or if there was an error on the physical drive linked to the logical drive, etc.
Precondition
The dir must be opened first, before calling this function. See dir_open, function for detailed explanation.

◆ dir_rewind()

fs_status_t dir_rewind ( dir_t dir)

This API function will will move read/write offset of the opened dir, to the beginning of the opened dir.

Parameters
[in]dirA pointer to the directory data structure, that acts as the opened directory identifier. See dir_t, structure for detailed explanation.
Return values
FSS_OKIf read/write offset of the dir was moved to the desired offset successfully.
FSS_GENERAL_ERRORIf the dir was not opened, or if there was an error on the physical drive linked to the logical drive, etc.
Precondition
The dir must be opened first, before calling this function. See dir_open, function for detailed explanation.