42 #define FLAG_FILE_CLOSED 0
43 #define FLAG_FILE_OPEN 1
48 #ifdef CFS_RAM_CONF_SIZE
49 #define CFS_RAM_SIZE CFS_RAM_CONF_SIZE
51 #define CFS_RAM_SIZE 4096
54 static struct filestate file;
55 static char filemem[CFS_RAM_SIZE];
61 if(file.flag == FLAG_FILE_CLOSED) {
62 file.flag = FLAG_FILE_OPEN;
68 file.fileptr = file.filesize;
83 file.flag = FLAG_FILE_CLOSED;
87 cfs_read(
int f,
void *buf,
unsigned int len)
89 if(file.fileptr + len >
sizeof(filemem)) {
90 len =
sizeof(filemem) - file.fileptr;
93 if(file.fileptr + len > file.filesize) {
94 len = file.filesize - file.fileptr;
98 memcpy(buf, &filemem[file.fileptr], len);
107 cfs_write(
int f,
const void *buf,
unsigned int len)
109 if(file.fileptr >=
sizeof(filemem)) {
112 if(file.fileptr + len >
sizeof(filemem)) {
113 len =
sizeof(filemem) - file.fileptr;
116 if(file.fileptr + len > file.filesize) {
118 file.filesize = file.fileptr + len;
122 memcpy(&filemem[file.fileptr], buf, len);
134 if(o > file.filesize) {
140 return (cfs_offset_t)-1;