From cbf7f740e4d61d3807308baf8af9adf8c6223ee6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 20 May 2011 18:45:33 +1000 Subject: SWORD25: Re-implement two LUA library I/O functions necessary for detecting and creating the config.lua configuration file --- engines/sword25/util/lua/lauxlib.cpp | 6 +++++- engines/sword25/util/lua/liolib.cpp | 15 ++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) (limited to 'engines/sword25') diff --git a/engines/sword25/util/lua/lauxlib.cpp b/engines/sword25/util/lua/lauxlib.cpp index 526b1c84ab..ce61827e0f 100644 --- a/engines/sword25/util/lua/lauxlib.cpp +++ b/engines/sword25/util/lua/lauxlib.cpp @@ -540,7 +540,11 @@ static const char *getF (lua_State *L, void *ud, size_t *size) { static int errfile (lua_State *L, const char *what, int fnameindex) { - return luaL_error(L, "LUA function errfile has been removed in ScummVM"); + const char *serr = "General error"; + const char *filename = lua_tostring(L, fnameindex) + 1; + lua_pushfstring(L, "cannot %s %s: %s", what, filename, serr); + lua_remove(L, fnameindex); + return LUA_ERRFILE; } diff --git a/engines/sword25/util/lua/liolib.cpp b/engines/sword25/util/lua/liolib.cpp index f9bad30aed..aea6c328d8 100644 --- a/engines/sword25/util/lua/liolib.cpp +++ b/engines/sword25/util/lua/liolib.cpp @@ -27,7 +27,20 @@ static const char *const fnames[] = {"input", "output"}; static int pushresult (lua_State *L, int i, const char *filename) { - return luaL_error(L, "LUA file I/O functions have been removed in ScummVM"); + int en = 0; /*errno;*/ // Currently hardcoded for ScumMVM, this may need to be changed + if (i) { + lua_pushboolean(L, 1); + return 1; + } + else { + lua_pushnil(L); + if (filename) + lua_pushfstring(L, "%s: %s", filename, "General error" /*strerror(en)*/); + else + lua_pushfstring(L, "%s", "General error" /*strerror(en)*/); + lua_pushinteger(L, en); + return 3; + } } -- cgit v1.2.3