sd-reader
Functions
FAT directory functions
FAT support

Functions for managing directories. More...

Functions

struct fat_dir_struct * fat_open_dir (struct fat_fs_struct *fs, const struct fat_dir_entry_struct *dir_entry)
 Opens a directory.
void fat_close_dir (struct fat_dir_struct *dd)
 Closes a directory descriptor.
uint8_t fat_read_dir (struct fat_dir_struct *dd, struct fat_dir_entry_struct *dir_entry)
 Reads the next directory entry contained within a parent directory.
uint8_t fat_reset_dir (struct fat_dir_struct *dd)
 Resets a directory handle.
uint8_t fat_create_dir (struct fat_dir_struct *parent, const char *dir, struct fat_dir_entry_struct *dir_entry)
 Creates a directory.
uint8_t fat_delete_dir (struct fat_fs_struct *fs, struct fat_dir_entry_struct *dir_entry)
 Deletes a directory.
uint8_t fat_move_dir (struct fat_fs_struct *fs, struct fat_dir_entry_struct *dir_entry, struct fat_dir_struct *parent_new, const char *dir_new)
 Moves or renames a directory.

Detailed Description

Functions for managing directories.


Function Documentation

void fat_close_dir ( struct fat_dir_struct *  dd)

Closes a directory descriptor.

This function destroys a directory descriptor which was previously obtained by calling fat_open_dir(). When this function returns, the given descriptor will be invalid.

Parameters:
[in]ddThe directory descriptor to close.
See also:
fat_open_dir
uint8_t fat_create_dir ( struct fat_dir_struct *  parent,
const char *  dir,
struct fat_dir_entry_struct dir_entry 
)

Creates a directory.

Creates a directory and obtains its directory entry. If the directory to create already exists, its directory entry will be returned within the dir_entry parameter.

Note:
The notes which apply to fat_create_file() also apply to this function.
Parameters:
[in]parentThe handle of the parent directory of the new directory.
[in]dirThe name of the directory to create.
[out]dir_entryThe directory entry to fill for the new directory.
Returns:
0 on failure, 1 on success.
See also:
fat_delete_dir
uint8_t fat_delete_dir ( struct fat_fs_struct *  fs,
struct fat_dir_entry_struct dir_entry 
)

Deletes a directory.

This is just a synonym for fat_delete_file(). If a directory is deleted without first deleting its subdirectories and files, disk space occupied by these files will get wasted as there is no chance to release it and mark it as free.

Parameters:
[in]fsThe filesystem on which to operate.
[in]dir_entryThe directory entry of the directory to delete.
Returns:
0 on failure, 1 on success.
See also:
fat_create_dir
uint8_t fat_move_dir ( struct fat_fs_struct *  fs,
struct fat_dir_entry_struct dir_entry,
struct fat_dir_struct *  parent_new,
const char *  dir_new 
)

Moves or renames a directory.

This is just a synonym for fat_move_file().

Parameters:
[in]fsThe filesystem on which to operate.
[in,out]dir_entryThe directory entry of the directory to move.
[in]parent_newThe handle of the new parent directory.
[in]dir_newThe directory's new name.
Returns:
0 on failure, 1 on success.
See also:
fat_create_dir, fat_delete_dir, fat_move_file
struct fat_dir_struct* fat_open_dir ( struct fat_fs_struct *  fs,
const struct fat_dir_entry_struct dir_entry 
) [read]

Opens a directory.

Parameters:
[in]fsThe filesystem on which the directory to open resides.
[in]dir_entryThe directory entry which stands for the directory to open.
Returns:
An opaque directory descriptor on success, 0 on failure.
See also:
fat_close_dir
uint8_t fat_read_dir ( struct fat_dir_struct *  dd,
struct fat_dir_entry_struct dir_entry 
)

Reads the next directory entry contained within a parent directory.

Parameters:
[in]ddThe descriptor of the parent directory from which to read the entry.
[out]dir_entryPointer to a buffer into which to write the directory entry information.
Returns:
0 on failure, 1 on success.
See also:
fat_reset_dir
uint8_t fat_reset_dir ( struct fat_dir_struct *  dd)

Resets a directory handle.

Resets the directory handle such that reading restarts with the first directory entry.

Parameters:
[in]ddThe directory handle to reset.
Returns:
0 on failure, 1 on success.
See also:
fat_read_dir