Re #3001: f_open() did not support append mode (in simulator only)
This commit is contained in:
@@ -819,10 +819,10 @@ FRESULT f_open (FIL * fil, const TCHAR *name, BYTE flag)
|
|||||||
fil->fsize = tmp.st_size;
|
fil->fsize = tmp.st_size;
|
||||||
fil->fptr = 0;
|
fil->fptr = 0;
|
||||||
}
|
}
|
||||||
fil->fs = (FATFS*)fopen(realPath, (flag & FA_WRITE) ? "wb+" : "rb+");
|
fil->fs = (FATFS*)fopen(realPath, (flag & FA_WRITE) ? ((flag & FA_CREATE_ALWAYS) ? "wb+" : "ab+") : "rb+");
|
||||||
fil->fptr = 0;
|
fil->fptr = 0;
|
||||||
if (fil->fs) {
|
if (fil->fs) {
|
||||||
TRACE("f_open(%s) = %p", path, (FILE*)fil->fs);
|
TRACE("f_open(%s, %x) = %p", path, flag, (FILE*)fil->fs);
|
||||||
return FR_OK;
|
return FR_OK;
|
||||||
}
|
}
|
||||||
TRACE("f_open(%s) = error %d (%s)", path, errno, strerror(errno));
|
TRACE("f_open(%s) = error %d (%s)", path, errno, strerror(errno));
|
||||||
@@ -856,6 +856,19 @@ FRESULT f_lseek (FIL* fil, DWORD offset)
|
|||||||
return FR_OK;
|
return FR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UINT f_size(FIL* fil)
|
||||||
|
{
|
||||||
|
if (fil && fil->fs) {
|
||||||
|
long curr = ftell((FILE*)fil->fs);
|
||||||
|
fseek((FILE*)fil->fs, 0, SEEK_END);
|
||||||
|
long size = ftell((FILE*)fil->fs);
|
||||||
|
fseek((FILE*)fil->fs, curr, SEEK_SET);
|
||||||
|
TRACE("f_size(%p) %u", fil->fs, size);
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
FRESULT f_close (FIL * fil)
|
FRESULT f_close (FIL * fil)
|
||||||
{
|
{
|
||||||
if (fil && fil->fs) {
|
if (fil && fil->fs) {
|
||||||
|
|||||||
Vendored
+5
-1
@@ -238,7 +238,11 @@ TCHAR* f_gets (TCHAR* buff, int len, FIL* fp); /* Get a string from the fil
|
|||||||
#define f_eof(fp) ((int)((fp)->fptr == (fp)->fsize))
|
#define f_eof(fp) ((int)((fp)->fptr == (fp)->fsize))
|
||||||
#define f_error(fp) ((fp)->err)
|
#define f_error(fp) ((fp)->err)
|
||||||
#define f_tell(fp) ((fp)->fptr)
|
#define f_tell(fp) ((fp)->fptr)
|
||||||
#define f_size(fp) ((fp)->fsize)
|
#if !defined(SIMU)
|
||||||
|
#define f_size(fp) ((fp)->fsize)
|
||||||
|
#else
|
||||||
|
UINT f_size(FIL* fil);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef EOF
|
#ifndef EOF
|
||||||
#define EOF (-1)
|
#define EOF (-1)
|
||||||
|
|||||||
Reference in New Issue
Block a user