From 1dc0c46d930d8e59902e9b3ce92aab21a5311d78 Mon Sep 17 00:00:00 2001 From: Maurus Cuelenaere Date: Fri, 17 Jul 2009 11:09:51 +0000 Subject: Lua IOlib: when opening files for writing/appending, check if they exist and if not, add O_CREAT. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21918 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/lua/liolib.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/plugins/lua/liolib.c b/apps/plugins/lua/liolib.c index 0651ca971e..08aed42388 100644 --- a/apps/plugins/lua/liolib.c +++ b/apps/plugins/lua/liolib.c @@ -156,6 +156,8 @@ static int io_open (lua_State *L) { flags = O_WRONLY | O_APPEND; break; } } + if((*mode == 'w' || *mode == 'a') && !rb->file_exists(filename)) + flags |= O_CREAT; *pf = rb->open(filename, flags); return (*pf < 0) ? pushresult(L, 0, filename) : 1; } -- cgit v1.2.3