Lua f_open in "a" mode added

This commit is contained in:
bsongis
2015-03-31 20:39:46 +02:00
parent ad9c2e0818
commit 84fc2007f5
+4 -2
View File
@@ -246,13 +246,15 @@ static int io_open (lua_State *L) {
LStream *p = newfile(L); LStream *p = newfile(L);
#if defined(USE_FATFS) #if defined(USE_FATFS)
BYTE mode; BYTE mode;
if (!md || *md == 'r') if (!strcmp(md, "r"))
mode = FA_READ; mode = FA_READ;
else if (*md == 'w') else if (!strcmp(md, "w") || !strcmp(md, "a"))
mode = FA_WRITE; mode = FA_WRITE;
else else
luaL_argerror(L, (2), ("invalid mode")); luaL_argerror(L, (2), ("invalid mode"));
FRESULT result = f_open(&p->f, filename, mode); FRESULT result = f_open(&p->f, filename, mode);
if (result == FR_OK && !strcmp(md, "a"))
result = f_lseek(&p->f, f_size(&p->f));
return result == FR_OK ? 1 : 0; return result == FR_OK ? 1 : 0;
#else #else
const char *mode = md; /* to traverse/check mode */ const char *mode = md; /* to traverse/check mode */