diff options
author | Maurus Cuelenaere <mcuelenaere@gmail.com> | 2009-07-17 11:09:51 +0000 |
---|---|---|
committer | Maurus Cuelenaere <mcuelenaere@gmail.com> | 2009-07-17 11:09:51 +0000 |
commit | 1dc0c46d930d8e59902e9b3ce92aab21a5311d78 (patch) | |
tree | f726c67652a53e648365d152c8d3323faf365636 /apps/plugins/lua | |
parent | 749c2b79d91ce97fdb562ebc5fd9d0e2aae4748c (diff) | |
download | rockbox-1dc0c46d930d8e59902e9b3ce92aab21a5311d78.tar.gz rockbox-1dc0c46d930d8e59902e9b3ce92aab21a5311d78.zip |
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
Diffstat (limited to 'apps/plugins/lua')
-rw-r--r-- | apps/plugins/lua/liolib.c | 2 |
1 files changed, 2 insertions, 0 deletions
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) { | |||
156 | flags = O_WRONLY | O_APPEND; break; | 156 | flags = O_WRONLY | O_APPEND; break; |
157 | } | 157 | } |
158 | } | 158 | } |
159 | if((*mode == 'w' || *mode == 'a') && !rb->file_exists(filename)) | ||
160 | flags |= O_CREAT; | ||
159 | *pf = rb->open(filename, flags); | 161 | *pf = rb->open(filename, flags); |
160 | return (*pf < 0) ? pushresult(L, 0, filename) : 1; | 162 | return (*pf < 0) ? pushresult(L, 0, filename) : 1; |
161 | } | 163 | } |