diff options
| author | ruki <[email protected]> | 2025-10-11 15:55:56 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-10-11 15:55:56 +0800 |
| commit | c666f0560bbb68d062c57923821607c2d893340e (patch) | |
| tree | c1b4e3a19ce1291769834aa84853e0228151580f /xmake/core/base/os.lua | |
| parent | b3bc1f49a705b8b1a15d14194a239f43be17a95d (diff) | |
add copy_if_different for os.cp
Diffstat (limited to 'xmake/core/base/os.lua')
| -rw-r--r-- | xmake/core/base/os.lua | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua index e6422c549..647c76c50 100644 --- a/xmake/core/base/os.lua +++ b/xmake/core/base/os.lua @@ -72,6 +72,7 @@ function os._cp(src, dst, rootdir, opt) -- is file or link? local symlink = opt.symlink local writeable = opt.writeable + local copy_if_different = opt.copy_if_different if os.isfile(src) or (symlink and os.islink(src)) then -- the destination is directory? append the filename @@ -87,7 +88,7 @@ function os._cp(src, dst, rootdir, opt) if opt.force and os.isfile(dst) then os.rmfile(dst) end - if not os.cpfile(src, dst, symlink, writeable) then + if not os.cpfile(src, dst, symlink, writeable, copy_if_different) then local errors = os.strerror() if symlink and os.islink(src) then local reallink = os.readlink(src) @@ -109,7 +110,7 @@ function os._cp(src, dst, rootdir, opt) end -- copy directory - if not os.cpdir(src, dst, symlink) then + if not os.cpdir(src, dst, symlink, copy_if_different) then return false, string.format("cannot copy directory %s to %s, %s", src, dst, os.strerror()) end else @@ -497,6 +498,11 @@ function os.filedirs(pattern, callback) end -- copy files or directories and we can reserve the source directory structure +-- +-- @param srcpath the source file path +-- @param dstpath the destination file path +-- @param opt the copy option. e.g. {rootdir, symlink, writeable, force, copy_if_different} +-- -- e.g. os.cp("src/**.h", "/tmp/", {rootdir = "src", symlink = true}) function os.cp(srcpath, dstpath, opt) |
