Hanna
Sourcecode Batteriemanagementsystem
fat.h
gehe zur Dokumentation dieser Datei
1 
14 /*
15  * Copyright (c) 2006-2011 by Roland Riegel <feedback@roland-riegel.de>
16  *
17  * This file is free software; you can redistribute it and/or modify
18  * it under the terms of either the GNU General Public License version 2
19  * or the GNU Lesser General Public License version 2.1, both as
20  * published by the Free Software Foundation.
21  */
22 
23 #ifndef FAT_H
24 #define FAT_H
25 
26 #include <stdint.h>
27 #include "fat_config.h"
28 
29 #ifdef __cplusplus
30 extern "C"
31 {
32 #endif
33 
52 #define FAT_ATTRIB_READONLY (1 << 0)
53 
54 #define FAT_ATTRIB_HIDDEN (1 << 1)
55 
56 #define FAT_ATTRIB_SYSTEM (1 << 2)
57 
58 #define FAT_ATTRIB_VOLUME (1 << 3)
59 
60 #define FAT_ATTRIB_DIR (1 << 4)
61 
62 #define FAT_ATTRIB_ARCHIVE (1 << 5)
63 
65 #define FAT_SEEK_SET 0
66 
67 #define FAT_SEEK_CUR 1
68 
69 #define FAT_SEEK_END 2
70 
75 struct partition_struct;
76 struct fat_fs_struct;
77 struct fat_file_struct;
78 struct fat_dir_struct;
79 
85 {
87  char long_name[32];
89  uint8_t attributes;
90 #if FAT_DATETIME_SUPPORT
91 
95 #endif
96 
97  cluster_t cluster;
99  uint32_t file_size;
101  offset_t entry_offset;
102 };
103 
104 struct fat_fs_struct* fat_open ( struct partition_struct* partition );
105 void fat_close ( struct fat_fs_struct* fs );
106 
107 struct fat_file_struct* fat_open_file ( struct fat_fs_struct* fs, const struct fat_dir_entry_struct* dir_entry );
108 void fat_close_file ( struct fat_file_struct* fd );
109 intptr_t fat_read_file ( struct fat_file_struct* fd, uint8_t* buffer, uintptr_t buffer_len );
110 intptr_t fat_write_file ( struct fat_file_struct* fd, const uint8_t* buffer, uintptr_t buffer_len );
111 uint8_t fat_seek_file ( struct fat_file_struct* fd, int32_t* offset, uint8_t whence );
112 uint8_t fat_resize_file ( struct fat_file_struct* fd, uint32_t size );
113 
114 struct fat_dir_struct* fat_open_dir ( struct fat_fs_struct* fs, const struct fat_dir_entry_struct* dir_entry );
115 void fat_close_dir ( struct fat_dir_struct* dd );
116 uint8_t fat_read_dir ( struct fat_dir_struct* dd, struct fat_dir_entry_struct* dir_entry );
117 uint8_t fat_reset_dir ( struct fat_dir_struct* dd );
118 
119 uint8_t fat_create_file ( struct fat_dir_struct* parent, const char* file, struct fat_dir_entry_struct* dir_entry );
120 uint8_t fat_delete_file ( struct fat_fs_struct* fs, struct fat_dir_entry_struct* dir_entry );
121 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 );
122 uint8_t fat_create_dir ( struct fat_dir_struct* parent, const char* dir, struct fat_dir_entry_struct* dir_entry );
123 #define fat_delete_dir fat_delete_file
124 #define fat_move_dir fat_move_file
125 
126 void fat_get_file_modification_date ( const struct fat_dir_entry_struct* dir_entry, uint16_t* year, uint8_t* month, uint8_t* day );
127 void fat_get_file_modification_time ( const struct fat_dir_entry_struct* dir_entry, uint8_t* hour, uint8_t* min, uint8_t* sec );
128 
129 uint8_t fat_get_dir_entry_of_path ( struct fat_fs_struct* fs, const char* path, struct fat_dir_entry_struct* dir_entry );
130 
131 offset_t fat_get_fs_size ( const struct fat_fs_struct* fs );
132 offset_t fat_get_fs_free ( const struct fat_fs_struct* fs );
133 
138 #ifdef __cplusplus
139 }
140 #endif
141 
142 #endif
143 
offset_t entry_offset
Definition: fat.h:101
struct fat_fs_struct * fat_open(struct partition_struct *partition)
Definition: fat.c:250
uint16_t modification_time
Definition: fat.h:92
void fat_close_file(struct fat_file_struct *fd)
Definition: fat.c:913
intptr_t fat_write_file(struct fat_file_struct *fd, const uint8_t *buffer, uintptr_t buffer_len)
Definition: fat.c:1032
struct fat_file_struct * fat_open_file(struct fat_fs_struct *fs, const struct fat_dir_entry_struct *dir_entry)
Definition: fat.c:878
struct fat_dir_struct * fat_open_dir(struct fat_fs_struct *fs, const struct fat_dir_entry_struct *dir_entry)
Definition: fat.c:1324
uint16_t modification_date
Definition: fat.h:94
uint8_t fat_reset_dir(struct fat_dir_struct *dd)
Definition: fat.c:1487
void fat_get_file_modification_time(const struct fat_dir_entry_struct *dir_entry, uint8_t *hour, uint8_t *min, uint8_t *sec)
Definition: fat.c:2273
void fat_close_dir(struct fat_dir_struct *dd)
Definition: fat.c:1363
uint8_t fat_get_dir_entry_of_path(struct fat_fs_struct *fs, const char *path, struct fat_dir_entry_struct *dir_entry)
Definition: fat.c:808
uint8_t attributes
Definition: fat.h:89
uint8_t fat_seek_file(struct fat_file_struct *fd, int32_t *offset, uint8_t whence)
Definition: fat.c:1186
uint8_t fat_read_dir(struct fat_dir_struct *dd, struct fat_dir_entry_struct *dir_entry)
Definition: fat.c:1382
void fat_close(struct fat_fs_struct *fs)
Definition: fat.c:302
SD-Card Reader Bibliothek von Roland Riegel.
void fat_get_file_modification_date(const struct fat_dir_entry_struct *dir_entry, uint16_t *year, uint8_t *month, uint8_t *day)
Definition: fat.c:2253
uint8_t fat_resize_file(struct fat_file_struct *fd, uint32_t size)
Definition: fat.c:1239
uint32_t file_size
Definition: fat.h:99
uint8_t fat_create_dir(struct fat_dir_struct *parent, const char *dir, struct fat_dir_entry_struct *dir_entry)
Definition: fat.c:2139
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)
Definition: fat.c:2083
cluster_t cluster
Definition: fat.h:97
intptr_t fat_read_file(struct fat_file_struct *fd, uint8_t *buffer, uintptr_t buffer_len)
Definition: fat.c:942
offset_t fat_get_fs_free(const struct fat_fs_struct *fs)
Definition: fat.c:2348
uint8_t fat_delete_file(struct fat_fs_struct *fs, struct fat_dir_entry_struct *dir_entry)
Definition: fat.c:2018
offset_t fat_get_fs_size(const struct fat_fs_struct *fs)
Definition: fat.c:2326
char long_name[32]
Definition: fat.h:87
uint8_t fat_create_file(struct fat_dir_struct *parent, const char *file, struct fat_dir_entry_struct *dir_entry)
Definition: fat.c:1971