1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Maurus Cuelenaere 2009-07-17 11:09:51 +00:00
parent 749c2b79d9
commit 1dc0c46d93

View file

@ -156,6 +156,8 @@ static int io_open (lua_State *L) {
flags = O_WRONLY | O_APPEND; break; flags = O_WRONLY | O_APPEND; break;
} }
} }
if((*mode == 'w' || *mode == 'a') && !rb->file_exists(filename))
flags |= O_CREAT;
*pf = rb->open(filename, flags); *pf = rb->open(filename, flags);
return (*pf < 0) ? pushresult(L, 0, filename) : 1; return (*pf < 0) ? pushresult(L, 0, filename) : 1;
} }