This commit is contained in:
Bertrand Songis
2016-03-11 18:07:40 +01:00
parent e1a865650f
commit eb9e6d3c80
2 changed files with 14 additions and 8 deletions
+6 -5
View File
@@ -18,7 +18,7 @@
* GNU General Public License for more details. * GNU General Public License for more details.
*/ */
#include "../../opentx.h" #include "opentx.h"
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <stdarg.h> #include <stdarg.h>
@@ -386,7 +386,7 @@ void StopSimu()
{ {
main_thread_running = 0; main_thread_running = 0;
#if !defined(CPUARM) #if !defined(CPUARM)
pthread_join(main_thread_pid, NULL); pthread_join(main_thread_pid, NULL);
#endif #endif
} }
@@ -771,12 +771,13 @@ FRESULT f_mount (FATFS* ,const TCHAR*, BYTE opt)
FRESULT f_open (FIL * fil, const TCHAR *name, BYTE flag) FRESULT f_open (FIL * fil, const TCHAR *name, BYTE flag)
{ {
char *path = convertSimuPath(name); char * path = convertSimuPath(name);
char * realPath = findTrueFileName(path); char * realPath = findTrueFileName(path);
fil->fs = 0;
if (!(flag & FA_WRITE)) { if (!(flag & FA_WRITE)) {
struct stat tmp; struct stat tmp;
if (stat(realPath, &tmp)) { if (stat(realPath, &tmp)) {
TRACE("f_open(%s) = INVALID_NAME", path); TRACE("f_open(%s) = INVALID_NAME (FIL %p)", path, fil);
return FR_INVALID_NAME; return FR_INVALID_NAME;
} }
fil->fsize = tmp.st_size; fil->fsize = tmp.st_size;
@@ -788,7 +789,7 @@ FRESULT f_open (FIL * fil, const TCHAR *name, BYTE flag)
TRACE("f_open(%s, %x) = %p (FIL %p)", path, flag, fil->fs, fil); TRACE("f_open(%s, %x) = %p (FIL %p)", path, flag, fil->fs, fil);
return FR_OK; return FR_OK;
} }
TRACE("f_open(%s) = error %d (%s)", path, errno, strerror(errno)); TRACE("f_open(%s) = error %d (%s) (FIL %p)", path, errno, strerror(errno), fil);
return FR_INVALID_NAME; return FR_INVALID_NAME;
} }
+8 -3
View File
@@ -253,9 +253,14 @@ static int io_open (lua_State *L) {
else if (*md == 'a') else if (*md == 'a')
mode = FA_WRITE | FA_OPEN_ALWAYS; // always open file (create it if necessary) mode = FA_WRITE | FA_OPEN_ALWAYS; // always open file (create it if necessary)
FRESULT result = f_open(&p->f, filename, mode); FRESULT result = f_open(&p->f, filename, mode);
if (result == FR_OK && *md == 'a') if (result == FR_OK) {
result = f_lseek(&p->f, f_size(&p->f)); // seek to the end of the file if (*md == 'a')
return result == FR_OK ? 1 : 0; f_lseek(&p->f, f_size(&p->f)); // seek to the end of the file
return 1;
}
else {
return luaL_fileresult(L, 0, filename);
}
#else #else
const char *mode = md; /* to traverse/check mode */ const char *mode = md; /* to traverse/check mode */
luaL_argcheck(L, lua_checkmode(mode), 2, "invalid mode"); luaL_argcheck(L, lua_checkmode(mode), 2, "invalid mode");