summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorruki <[email protected]>2022-08-31 00:50:27 +0800
committerruki <[email protected]>2022-08-31 00:50:27 +0800
commit8c11d185b753f7c53439929aa91f04edba772836 (patch)
tree2c76e8f30ed2dfb7db847a46a043c11668b68708 /core
parent3e398cf349c1ff3b9e9ebfa92f9dff99dfa8a97f (diff)
improve symlink
Diffstat (limited to 'core')
-rw-r--r--core/src/xmake/os/islink.c16
1 files changed, 2 insertions, 14 deletions
diff --git a/core/src/xmake/os/islink.c b/core/src/xmake/os/islink.c
index c7fec236e..b5662c369 100644
--- a/core/src/xmake/os/islink.c
+++ b/core/src/xmake/os/islink.c
@@ -29,9 +29,6 @@
* includes
*/
#include "prefix.h"
-#ifndef TB_CONFIG_OS_WINDOWS
-# include <sys/stat.h>
-#endif
/* //////////////////////////////////////////////////////////////////////////////////////
* implementation
@@ -46,16 +43,7 @@ tb_int_t xm_os_islink(lua_State* lua)
tb_check_return_val(path, 0);
// is link?
-#if defined(TB_CONFIG_OS_WINDOWS)
- lua_pushboolean(lua, tb_false);
-#elif defined(TB_CONFIG_POSIX_HAVE_STAT64)
- struct stat64 st = {0};
- lua_pushboolean(lua, !lstat64(path, &st) && S_ISLNK(st.st_mode));
-#else
- struct stat st = {0};
- lua_pushboolean(lua, !lstat(path, &st) && S_ISLNK(st.st_mode));
-#endif
-
- // ok
+ tb_file_info_t info = {0};
+ lua_pushboolean(lua, tb_file_info(path, &info) && (info.flags & TB_FILE_FLAG_LINK));
return 1;
}