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)
69 #define FILE_CREATE (1 << 5)
71 struct fat_node list_node
;
74 //-----------------------------------------------------------------------------
76 //-----------------------------------------------------------------------------
80 void fl_attach_locks(void (*lock
)(void), void (*unlock
)(void));
81 int fl_attach_media(fn_diskio_read rd
, fn_diskio_write wr
);
82 void fl_shutdown(void);
85 void* fl_fopen(const char *path
, const char *modifiers
);
86 void fl_fclose(void *file
);
87 int fl_fflush(void *file
);
88 int fl_fgetc(void *file
);
89 char * fl_fgets(char *s
, int n
, void *f
);
90 int fl_fputc(int c
, void *file
);
91 int fl_fputs(const char * str
, void *file
);
92 int fl_fwrite(const void * data
, int size
, int count
, void *file
);
93 int fl_fread(void * data
, int size
, int count
, void *file
);
94 int fl_fseek(void *file
, long offset
, int origin
);
95 int fl_fgetpos(void *file
, uint32
* position
);
96 long fl_ftell(void *f
);
98 int fl_remove(const char * filename
);
100 // Equivelant dirent.h
101 typedef struct fs_dir_list_status FL_DIR
;
102 typedef struct fs_dir_ent fl_dirent
;
104 FL_DIR
* fl_opendir(const char* path
, FL_DIR
*dir
);
105 int fl_readdir(FL_DIR
*dirls
, fl_dirent
*entry
);
106 int fl_closedir(FL_DIR
* dir
);
109 void fl_listdirectory(const char *path
);
110 int fl_createdirectory(const char *path
);
111 int fl_is_dir(const char *path
);
113 int fl_format(uint32 volume_sectors
, const char *name
);
116 #ifdef FATFS_INC_TEST_HOOKS
117 struct fatfs
* fl_get_fs(void);
120 //-----------------------------------------------------------------------------
121 // Stdio file I/O names
122 //-----------------------------------------------------------------------------
123 #ifdef USE_FILELIB_STDIO_COMPAT_NAMES
127 #define fopen(a,b) fl_fopen(a, b)
128 #define fclose(a) fl_fclose(a)
129 #define fflush(a) fl_fflush(a)
130 #define fgetc(a) fl_fgetc(a)
131 #define fgets(a,b,c) fl_fgets(a, b, c)
132 #define fputc(a,b) fl_fputc(a, b)
133 #define fputs(a,b) fl_fputs(a, b)
134 #define fwrite(a,b,c,d) fl_fwrite(a, b, c, d)
135 #define fread(a,b,c,d) fl_fread(a, b, c, d)
136 #define fseek(a,b,c) fl_fseek(a, b, c)
137 #define fgetpos(a,b) fl_fgetpos(a, b)
138 #define ftell(a) fl_ftell(a)
139 #define feof(a) fl_feof(a)
140 #define remove(a) fl_remove(a)
141 #define mkdir(a) fl_createdirectory(a)