1 #ifndef __FAT_FILELIB_H__
2 #define __FAT_FILELIB_H__
5 #include "fat_access.h"
8 //-----------------------------------------------------------------------------
10 //-----------------------------------------------------------------------------
27 //-----------------------------------------------------------------------------
29 //-----------------------------------------------------------------------------
35 uint32 CurrentCluster
;
38 typedef struct sFL_FILE
44 int filelength_changed
;
45 char path
[FATFS_MAX_LONG_FILENAME
];
46 char filename
[FATFS_MAX_LONG_FILENAME
];
47 uint8 shortfilename
[11];
49 #ifdef FAT_CLUSTER_CACHE_ENTRIES
50 uint32 cluster_cache_idx
[FAT_CLUSTER_CACHE_ENTRIES
];
51 uint32 cluster_cache_data
[FAT_CLUSTER_CACHE_ENTRIES
];
55 struct cluster_lookup last_fat_lookup
;
57 // Read/Write sector buffer
58 uint8 file_data_sector
[FAT_SECTOR_SIZE
];
59 uint32 file_data_address
;
64 #define FILE_READ (1 << 0)
65 #define FILE_WRITE (1 << 1)
66 #define FILE_APPEND (1 << 2)
67 #define FILE_BINARY (1 << 3)
68 #define FILE_ERASE (1 << 4)
70 #define FILE_CREATE (1 << 5)
73 struct fat_node list_node
;
76 //-----------------------------------------------------------------------------
78 //-----------------------------------------------------------------------------
82 void fl_attach_locks(void (*lock
)(void), void (*unlock
)(void));
83 int fl_attach_media(fn_diskio_read rd
, fn_diskio_write wr
);
84 void fl_shutdown(void);
87 void* fl_fopen(const char *path
, const char *modifiers
);
88 void fl_fclose(void *file
);
89 int fl_fflush(void *file
);
90 int fl_fgetc(void *file
);
91 char * fl_fgets(char *s
, int n
, void *f
);
92 int fl_fputc(int c
, void *file
);
93 int fl_fputs(const char * str
, void *file
);
94 int fl_fwrite(const void * data
, int size
, int count
, void *file
);
95 int fl_fread(void * data
, int size
, int count
, void *file
);
96 int fl_fseek(void *file
, long offset
, int origin
);
97 int fl_fgetpos(void *file
, uint32
* position
);
98 long fl_ftell(void *f
);
100 int fl_remove(const char * filename
);
102 // Equivelant dirent.h
103 typedef struct fs_dir_list_status FL_DIR
;
104 typedef struct fs_dir_ent fl_dirent
;
106 FL_DIR
* fl_opendir(const char* path
, FL_DIR
*dir
);
107 int fl_readdir(FL_DIR
*dirls
, fl_dirent
*entry
);
108 int fl_closedir(FL_DIR
* dir
);
111 void fl_listdirectory(const char *path
);
112 int fl_createdirectory(const char *path
);
113 int fl_is_dir(const char *path
);
115 int fl_format(uint32 volume_sectors
, const char *name
);
118 #ifdef FATFS_INC_TEST_HOOKS
119 struct fatfs
* fl_get_fs(void);
122 //-----------------------------------------------------------------------------
123 // Stdio file I/O names
124 //-----------------------------------------------------------------------------
125 #ifdef USE_FILELIB_STDIO_COMPAT_NAMES
129 #define fopen(a,b) fl_fopen(a, b)
130 #define fclose(a) fl_fclose(a)
131 #define fflush(a) fl_fflush(a)
132 #define fgetc(a) fl_fgetc(a)
133 #define fgets(a,b,c) fl_fgets(a, b, c)
134 #define fputc(a,b) fl_fputc(a, b)
135 #define fputs(a,b) fl_fputs(a, b)
136 #define fwrite(a,b,c,d) fl_fwrite(a, b, c, d)
137 #define fread(a,b,c,d) fl_fread(a, b, c, d)
138 #define fseek(a,b,c) fl_fseek(a, b, c)
139 #define fgetpos(a,b) fl_fgetpos(a, b)
140 #define ftell(a) fl_ftell(a)
141 #define feof(a) fl_feof(a)
142 #define remove(a) fl_remove(a)
143 #define mkdir(a) fl_createdirectory(a)