aboutsummaryrefslogtreecommitdiff
path: root/src/lua.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lua.c')
-rw-r--r--src/lua.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/lua.c b/src/lua.c
index 3d35858..ef3c032 100644
--- a/src/lua.c
+++ b/src/lua.c
@@ -59,10 +59,15 @@ int _stream_file(lua_State* L){
const int CHUNK_SIZE = 4096;
uint64_t maxlen = 0;
uint64_t totallen = 0;
+ const char* mode = "w";
if(lua_gettop(L) > 2){
maxlen = lua_tointeger(L, 3);
}
+ if(lua_gettop(L) > 3){
+ mode = lua_tostring(L, 4);
+ }
+
lua_pushstring(L, "_read");
lua_gettable(L, 1);
stream_read_function rf = lua_touserdata(L, -1);
@@ -73,7 +78,7 @@ int _stream_file(lua_State* L){
const char* filename = lua_tostring(L, 2);
FILE *f;
- f = fopen(filename, "w");
+ f = fopen(filename, mode);
if(f == NULL){
luaI_error(L, -1, "unable to open file");
}