From a87c36d61e64242d70f443cf0b9085d27e3d5a85 Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Sun, 24 Mar 2024 15:32:03 +1300 Subject: [PATCH] fs: init function "issymlink" --- lfs.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lfs.c b/lfs.c index cfc7558..cf13ac9 100644 --- a/lfs.c +++ b/lfs.c @@ -358,6 +358,24 @@ fs_isfile(lua_State *L) return istype(L, "file"); } +/*** + * Returns true if the given path specifies a symbolic link. + * Will return false if either the given path + * does not specify a file or the path + * does not exist at all. + * + * On error returns nil, an error message and a + * platform-dependent error code. + * + * @function issymlink + * @tparam string path The path to check. + */ +static int +fs_issymlink(lua_State *L) +{ + return istype(L, "symlink"); +} + /*** * Creates a new directory, creating intermediate directories as required. * @@ -725,6 +743,7 @@ static const luaL_Reg fslib[] = { {"exists", fs_exists}, {"isdirectory", fs_isdirectory}, {"isfile", fs_isfile}, + {"issymlink", fs_issymlink}, {"mkdir", fs_mkdir}, {"mkpath", fs_mkpath}, {"move", fs_move},