diff --git a/Lua API.rst b/Lua API.rst index cd418a5e2..a616ac08b 100644 --- a/Lua API.rst +++ b/Lua API.rst @@ -1909,6 +1909,10 @@ and are only documented here for completeness: Lists files/directories in a directory. Returns: *file_names* or empty table if not found. Identical to ``dfhack.filesystem.listdir(path)``. +* ``dfhack.internal.strerror(errno)`` + + Wraps strerror() - returns a string describing a platform-specific error code + Core interpreter context ======================== diff --git a/library/LuaApi.cpp b/library/LuaApi.cpp index 26e158368..78f8d6f85 100644 --- a/library/LuaApi.cpp +++ b/library/LuaApi.cpp @@ -24,6 +24,7 @@ distribution. #include "Internal.h" +#include #include #include #include @@ -2102,11 +2103,13 @@ static void *checkaddr(lua_State *L, int idx, bool allow_null = false) static uint32_t getImageBase() { return Core::getInstance().p->getBase(); } static int getRebaseDelta() { return Core::getInstance().vinfo->getRebaseDelta(); } static int8_t getModstate() { return Core::getInstance().getModstate(); } +static std::string internal_strerror(int n) { return strerror(n); } static const LuaWrapper::FunctionReg dfhack_internal_module[] = { WRAP(getImageBase), WRAP(getRebaseDelta), WRAP(getModstate), + WRAPN(strerror, internal_strerror), { NULL, NULL } };