RPV Event driven kernel
Loading...
Searching...
No Matches
fat.h
Go to the documentation of this file.
1
7#pragma once
8
9#include <stddef.h>
10#include <stdint.h>
11#include <stdbool.h>
12
16#define MAX_FILE_NAME (256)
17
28typedef enum
29{
30 FILE_READ = 0x01,
31 FILE_WRITE = 0x02,
32 FILE_CREATE = 0x08,
34 FILE_APPEND = 0x30
37
53
60typedef struct
61{
62 uint8_t hour;
63 uint8_t minute;
64 uint8_t second;
66 uint8_t day;
67 uint8_t month;
68 uint16_t year;
71
78typedef struct
79{
84
89
96 union
97 {
98 uint8_t a8;
100 struct
101 {
102 bool r_only : 1;
103 bool archive : 1;
104 bool system : 1;
105 bool hidden : 1;
106 bool directory : 1;
108 } flags;
109
110 } attrib;
111
115 size_t filesize;
116
120 char full_name[MAX_FILE_NAME];
121
122} filinfo_t;
123
134void fat_getcwd(char *cwd);
135
146bool fat_exists(char const* path);
147
157bool fat_chdir(char const* cwd);
158
168bool fat_mkdir(char const* path);
169
179bool fat_unlink(char const* path);
180
192bool fat_mount(char const* path);
193
203bool fat_unmount(char const* path);
204
215bool fat_stat(char const* path, filinfo_t *fno);
216
224
231void fat_fclose(int fd);
232
244int fat_fopen(char const* path, file_access_t mode);
245
254size_t fat_fsize(int fd);
255
268size_t fat_fread(int fd, void *buffer, size_t nread);
269
280size_t fat_fwrite(int fd, void const* buffer, size_t nwrite);
281
300void fat_ls(char const* path, void const* ls_ctx,
301 void (*nxt_file)(void const* ls_ctx, filinfo_t const* fi));
file_access_t
File access mode flags.
Definition fat.h:29
@ FILE_APPEND
Definition fat.h:34
@ FILE_CREATE
Definition fat.h:32
@ FILE_CREATE_NEW
Definition fat.h:33
@ FILE_READ
Definition fat.h:30
@ FILE_WRITE
Definition fat.h:31
fat_error_code_t
FAT filesystem error codes.
Definition fat.h:45
@ FAT_NOT_FOUND
Definition fat.h:48
@ FAT_ERR_NOTSET
Definition fat.h:50
@ FAT_IO_ERROR
Definition fat.h:47
@ FAT_OK
Definition fat.h:46
@ FAT_ACCESS_DENIED
Definition fat.h:49
#define MAX_FILE_NAME
Maximum file name length (including null terminator).
Definition fat.h:16
void fat_fclose(int fd)
Closes an open file descriptor.
size_t fat_fwrite(int fd, void const *buffer, size_t nwrite)
Writes data to file.
bool fat_unmount(char const *path)
Unmounts a FAT filesystem.
void fat_getcwd(char *cwd)
Retrieves current working directory path.
size_t fat_fread(int fd, void *buffer, size_t nread)
Reads data from file.
bool fat_chdir(char const *cwd)
Changes current working directory.
bool fat_exists(char const *path)
Checks whether a file or directory exists.
bool fat_stat(char const *path, filinfo_t *fno)
Retrieves file or directory metadata.
fat_error_code_t fat_getcode(void)
Returns last FAT error code.
bool fat_mount(char const *path)
Mounts a FAT filesystem.
int fat_fopen(char const *path, file_access_t mode)
Opens a file.
bool fat_mkdir(char const *path)
Creates a new directory.
size_t fat_fsize(int fd)
Returns file size.
bool fat_unlink(char const *path)
Removes a file or directory.
void fat_ls(char const *path, void const *ls_ctx, void(*nxt_file)(void const *ls_ctx, filinfo_t const *fi))
Lists directory contents.
FAT timestamp structure.
Definition fat.h:61
uint8_t month
Definition fat.h:67
uint16_t year
Definition fat.h:68
uint8_t day
Definition fat.h:66
uint8_t second
Definition fat.h:64
uint8_t minute
Definition fat.h:63
uint8_t hour
Definition fat.h:62
File information structure.
Definition fat.h:79
fildatetime_t modify_time
Last modification timestamp.
Definition fat.h:88
bool archive
Definition fat.h:103
bool r_only
Definition fat.h:102
bool system
Definition fat.h:104
bool hidden
Definition fat.h:105
bool directory
Definition fat.h:106
size_t filesize
File size in bytes.
Definition fat.h:115
fildatetime_t create_time
File creation timestamp.
Definition fat.h:83
uint8_t a8
Definition fat.h:98