40 #define FLAG_FILE_CLOSED 0
41 #define FLAG_FILE_OPEN 1
42 eeprom_addr_t fileptr;
43 eeprom_addr_t filesize;
46 static struct filestate file;
48 #ifdef CFS_EEPROM_CONF_OFFSET
49 #define CFS_EEPROM_OFFSET CFS_EEPROM_CONF_OFFSET
51 #define CFS_EEPROM_OFFSET 0
58 if(file.flag == FLAG_FILE_CLOSED) {
59 file.flag = FLAG_FILE_OPEN;
65 file.fileptr = file.filesize;
80 file.flag = FLAG_FILE_CLOSED;
87 eeprom_read(CFS_EEPROM_OFFSET + file.fileptr, buf, len);
99 eeprom_write(CFS_EEPROM_OFFSET + file.fileptr, (
unsigned char *)buf, len);
int cfs_write(int f, const void *buf, unsigned int len)
Write data to an open file.
int cfs_open(const char *n, int f)
Open a file.
#define CFS_APPEND
Specify that cfs_open() should append written data to the file rather than overwriting it...
#define CFS_WRITE
Specify that cfs_open() should open a file for writing.
int cfs_opendir(struct cfs_dir *p, const char *n)
Open a directory for reading directory entries.
void cfs_close(int f)
Close an open file.
void eeprom_read(eeprom_addr_t addr, unsigned char *buf, int size)
Read data from the EEPROM.
#define CFS_SEEK_SET
Specify that cfs_seek() should compute the offset from the beginning of the file. ...
#define CFS_READ
Specify that cfs_open() should open a file for reading.
int cfs_read(int f, void *buf, unsigned int len)
Read data from an open file.
void eeprom_write(eeprom_addr_t addr, unsigned char *buf, int size)
Write a buffer into EEPROM.
int cfs_readdir(struct cfs_dir *p, struct cfs_dirent *e)
Read a directory entry.
int cfs_remove(const char *name)
Remove a file.
void cfs_closedir(struct cfs_dir *p)
Close a directory opened with cfs_opendir().
cfs_offset_t cfs_seek(int f, cfs_offset_t o, int w)
Seek to a specified position in an open file.