Hanna
Sourcecode Batteriemanagementsystem |
Datenstrukturen | |
struct | fat_dir_entry_struct |
Makrodefinitionen | |
#define | FAT_ATTRIB_ARCHIVE (1 << 5) |
#define | FAT_ATTRIB_DIR (1 << 4) |
#define | FAT_ATTRIB_HIDDEN (1 << 1) |
#define | FAT_ATTRIB_READONLY (1 << 0) |
#define | FAT_ATTRIB_SYSTEM (1 << 2) |
#define | FAT_ATTRIB_VOLUME (1 << 3) |
#define | FAT_SEEK_CUR 1 |
#define | FAT_SEEK_END 2 |
#define | FAT_SEEK_SET 0 |
Funktionen | |
void | fat_close_file (struct fat_file_struct *fd) |
uint8_t | fat_create_file (struct fat_dir_struct *parent, const char *file, struct fat_dir_entry_struct *dir_entry) |
uint8_t | fat_delete_file (struct fat_fs_struct *fs, struct fat_dir_entry_struct *dir_entry) |
uint8_t | fat_get_dir_entry_of_path (struct fat_fs_struct *fs, const char *path, struct fat_dir_entry_struct *dir_entry) |
void | fat_get_file_modification_date (const struct fat_dir_entry_struct *dir_entry, uint16_t *year, uint8_t *month, uint8_t *day) |
void | fat_get_file_modification_time (const struct fat_dir_entry_struct *dir_entry, uint8_t *hour, uint8_t *min, uint8_t *sec) |
uint8_t | fat_move_file (struct fat_fs_struct *fs, struct fat_dir_entry_struct *dir_entry, struct fat_dir_struct *parent_new, const char *file_new) |
struct fat_file_struct * | fat_open_file (struct fat_fs_struct *fs, const struct fat_dir_entry_struct *dir_entry) |
intptr_t | fat_read_file (struct fat_file_struct *fd, uint8_t *buffer, uintptr_t buffer_len) |
uint8_t | fat_resize_file (struct fat_file_struct *fd, uint32_t size) |
uint8_t | fat_seek_file (struct fat_file_struct *fd, int32_t *offset, uint8_t whence) |
static void | fat_set_file_modification_date (struct fat_dir_entry_struct *dir_entry, uint16_t year, uint8_t month, uint8_t day) |
static void | fat_set_file_modification_time (struct fat_dir_entry_struct *dir_entry, uint8_t hour, uint8_t min, uint8_t sec) |
intptr_t | fat_write_file (struct fat_file_struct *fd, const uint8_t *buffer, uintptr_t buffer_len) |
Functions for managing files.
#define FAT_ATTRIB_ARCHIVE (1 << 5) |
#define FAT_ATTRIB_SYSTEM (1 << 2) |
#define FAT_ATTRIB_VOLUME (1 << 3) |
#define FAT_SEEK_CUR 1 |
#define FAT_SEEK_END 2 |
#define FAT_SEEK_SET 0 |
void fat_close_file | ( | struct fat_file_struct * | fd | ) |
Closes a file.
[in] | fd | The file handle of the file to close. |
Definiert in Zeile 913 der Datei fat.c.
uint8_t fat_create_file | ( | struct fat_dir_struct * | parent, |
const char * | file, | ||
struct fat_dir_entry_struct * | dir_entry | ||
) |
Creates a file.
Creates a file and obtains the directory entry of the new file. If the file to create already exists, the directory entry of the existing file will be returned within the dir_entry parameter.
[in] | parent | The handle of the directory in which to create the file. |
[in] | file | The name of the file to create. |
[out] | dir_entry | The directory entry to fill for the new (or existing) file. |
Definiert in Zeile 1971 der Datei fat.c.
uint8_t fat_delete_file | ( | struct fat_fs_struct * | fs, |
struct fat_dir_entry_struct * | dir_entry | ||
) |
Deletes a file or directory.
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.
[in] | fs | The filesystem on which to operate. |
[in] | dir_entry | The directory entry of the file to delete. |
Definiert in Zeile 2018 der Datei fat.c.
uint8_t fat_get_dir_entry_of_path | ( | struct fat_fs_struct * | fs, |
const char * | path, | ||
struct fat_dir_entry_struct * | dir_entry | ||
) |
Retrieves the directory entry of a path.
The given path may both describe a file or a directory.
[in] | fs | The FAT filesystem on which to search. |
[in] | path | The path of which to read the directory entry. |
[out] | dir_entry | The directory entry to fill. |
Definiert in Zeile 808 der Datei fat.c.
void fat_get_file_modification_date | ( | const struct fat_dir_entry_struct * | dir_entry, |
uint16_t * | year, | ||
uint8_t * | month, | ||
uint8_t * | day | ||
) |
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.
[in] | fs | The filesystem on which to operate. |
[in] | dir_entry | The directory entry of the directory to delete. |
Moves or renames a directory.
This is just a synonym for fat_move_file().
[in] | fs | The filesystem on which to operate. |
[in,out] | dir_entry | The directory entry of the directory to move. |
[in] | parent_new | The handle of the new parent directory. |
[in] | dir_new | The directory's new name. |
Returns the modification date of a file.
[in] | dir_entry | The directory entry of which to return the modification date. |
[out] | year | The year the file was last modified. |
[out] | month | The month the file was last modified. |
[out] | day | The day the file was last modified. |
void fat_get_file_modification_time | ( | const struct fat_dir_entry_struct * | dir_entry, |
uint8_t * | hour, | ||
uint8_t * | min, | ||
uint8_t * | sec | ||
) |
Returns the modification time of a file.
[in] | dir_entry | The directory entry of which to return the modification time. |
[out] | hour | The hour the file was last modified. |
[out] | min | The min the file was last modified. |
[out] | sec | The sec the file was last modified. |
uint8_t fat_move_file | ( | struct fat_fs_struct * | fs, |
struct fat_dir_entry_struct * | dir_entry, | ||
struct fat_dir_struct * | parent_new, | ||
const char * | file_new | ||
) |
Moves or renames a file.
Changes a file's name, optionally moving it into another directory as well. Before calling this function, the target file name must not exist. Moving a file to a different filesystem (i.e. parent_new doesn't lie on fs) is not supported.
After successfully renaming (and moving) the file, the given directory entry is updated such that it points to the file's new location.
[in] | fs | The filesystem on which to operate. |
[in,out] | dir_entry | The directory entry of the file to move. |
[in] | parent_new | The handle of the new parent directory of the file. |
[in] | file_new | The file's new name. |
Definiert in Zeile 2083 der Datei fat.c.
struct fat_file_struct* fat_open_file | ( | struct fat_fs_struct * | fs, |
const struct fat_dir_entry_struct * | dir_entry | ||
) |
Opens a file on a FAT filesystem.
[in] | fs | The filesystem on which the file to open lies. |
[in] | dir_entry | The directory entry of the file to open. |
intptr_t fat_read_file | ( | struct fat_file_struct * | fd, |
uint8_t * | buffer, | ||
uintptr_t | buffer_len | ||
) |
Reads data from a file.
The data requested is read from the current file location.
[in] | fd | The file handle of the file from which to read. |
[out] | buffer | The buffer into which to write. |
[in] | buffer_len | The amount of data to read. |
Definiert in Zeile 942 der Datei fat.c.
uint8_t fat_resize_file | ( | struct fat_file_struct * | fd, |
uint32_t | size | ||
) |
Resizes a file to have a specific size.
Enlarges or shrinks the file pointed to by the file descriptor to have exactly the specified size.
If the file is truncated, all bytes having an equal or larger offset than the given size are lost. If the file is expanded, the additional bytes are allocated.
[in] | fd | The file decriptor of the file which to resize. |
[in] | size | The new size of the file. |
Definiert in Zeile 1239 der Datei fat.c.
uint8_t fat_seek_file | ( | struct fat_file_struct * | fd, |
int32_t * | offset, | ||
uint8_t | whence | ||
) |
Repositions the read/write file offset.
Changes the file offset where the next call to fat_read_file() or fat_write_file() starts reading/writing.
If the new offset is beyond the end of the file, fat_resize_file() is implicitly called, i.e. the file is expanded.
The new offset can be given in different ways determined by the whence
parameter:
*offset
is relative to the beginning of the file.*offset
is relative to the current file position.*offset
is relative to the end of the file.The resulting absolute offset is written to the location the offset
parameter points to.
Calling this function can also be used to retrieve the current file position:
[in] | fd | The file decriptor of the file on which to seek. |
[in,out] | offset | A pointer to the new offset, as affected by the whence parameter. The function writes the new absolute offset to this location before it returns. |
[in] | whence | Affects the way offset is interpreted, see above. |
Definiert in Zeile 1186 der Datei fat.c.
|
static |
Sets the modification time of a date.
[in] | dir_entry | The directory entry for which to set the modification date. |
[in] | year | The year the file was last modified. |
[in] | month | The month the file was last modified. |
[in] | day | The day the file was last modified. |
Definiert in Zeile 2293 der Datei fat.c.
|
static |
Sets the modification time of a file.
[in] | dir_entry | The directory entry for which to set the modification time. |
[in] | hour | The year the file was last modified. |
[in] | min | The month the file was last modified. |
[in] | sec | The day the file was last modified. |
Definiert in Zeile 2311 der Datei fat.c.
intptr_t fat_write_file | ( | struct fat_file_struct * | fd, |
const uint8_t * | buffer, | ||
uintptr_t | buffer_len | ||
) |
Writes data to a file.
The data is written to the current file location.
[in] | fd | The file handle of the file to which to write. |
[in] | buffer | The buffer from which to read the data to be written. |
[in] | buffer_len | The amount of data to write. |
buffer_len
on disk full) or -1 on failure. Definiert in Zeile 1032 der Datei fat.c.