summaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
authorruki <[email protected]>2022-08-31 12:51:20 +0800
committerGitHub <[email protected]>2022-08-31 12:51:20 +0800
commitcfb302ba06a479ffddcf28e8acf727bea5d638fa (patch)
tree7191ddbb89c4812cf0b28f2e7aa5d3027363adad /core/src
parent3e398cf349c1ff3b9e9ebfa92f9dff99dfa8a97f (diff)
parent6046e78b4d3ba893ef99f3e821736830dca1e5c2 (diff)
Merge pull request #2745 from xmake-io/symlink
improve symlink
Diffstat (limited to 'core/src')
-rwxr-xr-xcore/src/tbox/inc/linux/tbox.config.h1
-rwxr-xr-xcore/src/tbox/inc/macosx/tbox.config.h1
m---------core/src/tbox/tbox0
-rw-r--r--core/src/xmake/os/cpdir.c10
-rw-r--r--core/src/xmake/os/cpfile.c8
-rw-r--r--core/src/xmake/os/islink.c16
6 files changed, 18 insertions, 18 deletions
diff --git a/core/src/tbox/inc/linux/tbox.config.h b/core/src/tbox/inc/linux/tbox.config.h
index b2977ecbb..a1986b4be 100755
--- a/core/src/tbox/inc/linux/tbox.config.h
+++ b/core/src/tbox/inc/linux/tbox.config.h
@@ -148,6 +148,7 @@
#define TB_CONFIG_POSIX_HAVE_DLOPEN 1
#define TB_CONFIG_POSIX_HAVE_OPEN 1
#define TB_CONFIG_POSIX_HAVE_STAT64 1
+#define TB_CONFIG_POSIX_HAVE_LSTAT64 1
#define TB_CONFIG_POSIX_HAVE_GETHOSTNAME 1
#define TB_CONFIG_POSIX_HAVE_GETIFADDRS 1
#define TB_CONFIG_POSIX_HAVE_SEM_INIT 1
diff --git a/core/src/tbox/inc/macosx/tbox.config.h b/core/src/tbox/inc/macosx/tbox.config.h
index 261b82b29..59abf4acf 100755
--- a/core/src/tbox/inc/macosx/tbox.config.h
+++ b/core/src/tbox/inc/macosx/tbox.config.h
@@ -145,6 +145,7 @@
#define TB_CONFIG_POSIX_HAVE_OPEN 1
#if !defined(__arm64__) && !defined(__aarch64__)
# define TB_CONFIG_POSIX_HAVE_STAT64 1
+# define TB_CONFIG_POSIX_HAVE_LSTAT64 1
#else
/* #undef TB_CONFIG_POSIX_HAVE_STAT64 */
#endif
diff --git a/core/src/tbox/tbox b/core/src/tbox/tbox
-Subproject 96ed094143923dacafaec6eed10fc34e1106edc
+Subproject dc99c25f3c6fecafe1cf6791148f5656c007299
diff --git a/core/src/xmake/os/cpdir.c b/core/src/xmake/os/cpdir.c
index 1967cba49..eaf59f445 100644
--- a/core/src/xmake/os/cpdir.c
+++ b/core/src/xmake/os/cpdir.c
@@ -43,9 +43,13 @@ tb_int_t xm_os_cpdir(lua_State* lua)
tb_char_t const* dst = luaL_checkstring(lua, 2);
tb_check_return_val(src && dst, 0);
- // done os.cpdir(src, dst)
- lua_pushboolean(lua, tb_directory_copy(src, dst));
+ // init copy flags
+ tb_size_t flags = TB_FILE_COPY_NONE;
+ tb_bool_t is_symlink = lua_toboolean(lua, 3);
+ if (is_symlink)
+ flags |= TB_FILE_COPY_LINK;
- // ok
+ // do copy
+ lua_pushboolean(lua, tb_directory_copy(src, dst, flags));
return 1;
}
diff --git a/core/src/xmake/os/cpfile.c b/core/src/xmake/os/cpfile.c
index 4490172da..153f51de0 100644
--- a/core/src/xmake/os/cpfile.c
+++ b/core/src/xmake/os/cpfile.c
@@ -43,7 +43,13 @@ tb_int_t xm_os_cpfile(lua_State* lua)
tb_char_t const* dst = luaL_checkstring(lua, 2);
tb_check_return_val(src && dst, 0);
+ // init copy flags
+ tb_size_t flags = TB_FILE_COPY_NONE;
+ tb_bool_t is_symlink = lua_toboolean(lua, 3);
+ if (is_symlink)
+ flags |= TB_FILE_COPY_LINK;
+
// do copy
- lua_pushboolean(lua, tb_file_copy(src, dst));
+ lua_pushboolean(lua, tb_file_copy(src, dst, flags));
return 1;
}
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;
}