From 19afaa2feedaa6ec1e1774174ce752e7f2583484 Mon Sep 17 00:00:00 2001 From: ame Date: Fri, 1 Aug 2025 14:25:07 -0500 Subject: change stream modes --- src/lua.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/lua.c') 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"); } -- cgit v1.2.3