summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-08-31 00:47:29 +0800
committerruki <[email protected]>2022-08-31 00:47:29 +0800
commit1ac88d2b07043fff092b1d8d757ab391e59a057d (patch)
treed4b8df522d72da6e5c33d99b872215e5fb0ec3aa
parent20e5768e36de8c12314c2dacd344cf18807c66f9 (diff)
improve os.islink
m---------core/src/tbox/tbox0
-rw-r--r--core/src/xmake/os/isdir.c4
-rw-r--r--core/src/xmake/os/isfile.c4
-rw-r--r--core/src/xmake/os/islink.c13
4 files changed, 4 insertions, 17 deletions
diff --git a/core/src/tbox/tbox b/core/src/tbox/tbox
-Subproject c21437c8af85bf686d4bf44a9664d05c117a1ec
+Subproject 96ed094143923dacafaec6eed10fc34e1106edc
diff --git a/core/src/xmake/os/isdir.c b/core/src/xmake/os/isdir.c
index 850823a31..c49860581 100644
--- a/core/src/xmake/os/isdir.c
+++ b/core/src/xmake/os/isdir.c
@@ -42,10 +42,8 @@ tb_int_t xm_os_isdir(lua_State* lua)
tb_char_t const* path = luaL_checkstring(lua, 1);
tb_check_return_val(path, 0);
- // done os.isdir(path)
+ // is directory?
tb_file_info_t info = {0};
lua_pushboolean(lua, tb_file_info(path, &info) && (info.type == TB_FILE_TYPE_DIRECTORY));
-
- // ok
return 1;
}
diff --git a/core/src/xmake/os/isfile.c b/core/src/xmake/os/isfile.c
index 85e616828..bfc162d74 100644
--- a/core/src/xmake/os/isfile.c
+++ b/core/src/xmake/os/isfile.c
@@ -42,10 +42,8 @@ tb_int_t xm_os_isfile(lua_State* lua)
tb_char_t const* path = luaL_checkstring(lua, 1);
tb_check_return_val(path, 0);
- // done os.isfile(path)
+ // is file?
tb_file_info_t info = {0};
lua_pushboolean(lua, tb_file_info(path, &info) && (info.type == TB_FILE_TYPE_FILE));
-
- // ok
return 1;
}
diff --git a/core/src/xmake/os/islink.c b/core/src/xmake/os/islink.c
index c7fec236e..d70681cb5 100644
--- a/core/src/xmake/os/islink.c
+++ b/core/src/xmake/os/islink.c
@@ -46,16 +46,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;
}