mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-08 02:40:28 +00:00
Update redbean ProgramDirectory to raise Lua error for easier handling
This commit is contained in:
parent
3359af9fc9
commit
b25a7770f8
1 changed files with 6 additions and 0 deletions
|
@ -4584,6 +4584,12 @@ static int LuaProgramBrand(lua_State *L) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int LuaProgramDirectory(lua_State *L) {
|
static int LuaProgramDirectory(lua_State *L) {
|
||||||
|
struct stat st;
|
||||||
|
char *path = luaL_checkstring(L, 1);
|
||||||
|
// check to raise a Lua error, to allow it to be handled
|
||||||
|
if (stat(path, &st) == -1 || !S_ISDIR(st.st_mode)) {
|
||||||
|
return luaL_argerror(L, 1, "not a directory");
|
||||||
|
}
|
||||||
return LuaProgramString(L, ProgramDirectory);
|
return LuaProgramString(L, ProgramDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue