00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef FAT16_H
00019 #define FAT16_H
00020
00021 #include "fat16_config.h"
00022
00023 #include <stdint.h>
00024
00043 #define FAT16_ATTRIB_READONLY (1 << 0)
00044
00045 #define FAT16_ATTRIB_HIDDEN (1 << 1)
00046
00047 #define FAT16_ATTRIB_SYSTEM (1 << 2)
00048
00049 #define FAT16_ATTRIB_VOLUME (1 << 3)
00050
00051 #define FAT16_ATTRIB_DIR (1 << 4)
00052
00053 #define FAT16_ATTRIB_ARCHIVE (1 << 5)
00054
00056 #define FAT16_SEEK_SET 0
00057
00058 #define FAT16_SEEK_CUR 1
00059
00060 #define FAT16_SEEK_END 2
00061
00066 struct partition_struct;
00067 struct fat16_fs_struct;
00068 struct fat16_file_struct;
00069 struct fat16_dir_struct;
00070
00075 struct fat16_dir_entry_struct
00076 {
00078 char long_name[32];
00080 uint8_t attributes;
00081 #if FAT16_DATETIME_SUPPORT
00082
00083 uint16_t modification_time;
00085 uint16_t modification_date;
00086 #endif
00087
00088 uint16_t cluster;
00090 uint32_t file_size;
00092 uint32_t entry_offset;
00093 };
00094
00095 struct fat16_fs_struct* fat16_open(struct partition_struct* partition);
00096 void fat16_close(struct fat16_fs_struct* fs);
00097
00098 struct fat16_file_struct* fat16_open_file(struct fat16_fs_struct* fs, const struct fat16_dir_entry_struct* dir_entry);
00099 void fat16_close_file(struct fat16_file_struct* fd);
00100 int16_t fat16_read_file(struct fat16_file_struct* fd, uint8_t* buffer, uint16_t buffer_len);
00101 int16_t fat16_write_file(struct fat16_file_struct* fd, const uint8_t* buffer, uint16_t buffer_len);
00102 uint8_t fat16_seek_file(struct fat16_file_struct* fd, int32_t* offset, uint8_t whence);
00103 uint8_t fat16_resize_file(struct fat16_file_struct* fd, uint32_t size);
00104
00105 struct fat16_dir_struct* fat16_open_dir(struct fat16_fs_struct* fs, const struct fat16_dir_entry_struct* dir_entry);
00106 void fat16_close_dir(struct fat16_dir_struct* dd);
00107 uint8_t fat16_read_dir(struct fat16_dir_struct* dd, struct fat16_dir_entry_struct* dir_entry);
00108 uint8_t fat16_reset_dir(struct fat16_dir_struct* dd);
00109
00110 uint8_t fat16_create_file(struct fat16_dir_struct* parent, const char* file, struct fat16_dir_entry_struct* dir_entry);
00111 uint8_t fat16_delete_file(struct fat16_fs_struct* fs, struct fat16_dir_entry_struct* dir_entry);
00112 uint8_t fat16_create_dir(struct fat16_dir_struct* parent, const char* dir, struct fat16_dir_entry_struct* dir_entry);
00113 #define fat16_delete_dir fat16_delete_file
00114
00115 void fat16_get_file_modification_date(const struct fat16_dir_entry_struct* dir_entry, uint16_t* year, uint8_t* month, uint8_t* day);
00116 void fat16_get_file_modification_time(const struct fat16_dir_entry_struct* dir_entry, uint8_t* hour, uint8_t* min, uint8_t* sec);
00117
00118 uint8_t fat16_get_dir_entry_of_path(struct fat16_fs_struct* fs, const char* path, struct fat16_dir_entry_struct* dir_entry);
00119
00120 uint32_t fat16_get_fs_size(const struct fat16_fs_struct* fs);
00121 uint32_t fat16_get_fs_free(const struct fat16_fs_struct* fs);
00122
00127 #endif
00128