diff options
| author | ruki <[email protected]> | 2022-08-31 22:39:10 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-08-31 22:39:10 +0800 |
| commit | 44d9b7cd8ef84a84bd8d898dddc419c385e02daf (patch) | |
| tree | 045b46d2029d30f092494887f8857bccc72cd5a2 /xmake/core/base/os.lua | |
| parent | df6efbec2309e41c67e6ffdc8386a600ca04c21d (diff) | |
improve os.cpfile
Diffstat (limited to 'xmake/core/base/os.lua')
| -rw-r--r-- | xmake/core/base/os.lua | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua index 271e5546d..ad33699f4 100644 --- a/xmake/core/base/os.lua +++ b/xmake/core/base/os.lua @@ -79,16 +79,15 @@ function os._cp(src, dst, rootdir, opt) end end - -- link file if reserve symlink - if opt and opt.symlink and os.islink(src) then - local reallink = os.readlink(src) - if not os.link(reallink, dst) then - return false, string.format("cannot link %s(%s) to %s, %s", src, reallink, dst, os.strerror()) - end - else - -- copy file - if not os.cpfile(src, dst) then - return false, string.format("cannot copy file %s to %s, %s", src, dst, os.strerror()) + -- copy or link file + local symlink = opt and opt.symlink + if not os.cpfile(src, dst, symlink) then + local errors = os.strerror() + if symlink and os.islink(src) then + local reallink = os.readlink(src) + return false, string.format("cannot link %s(%s) to %s, %s", src, reallink, dst, errors) + else + return false, string.format("cannot copy file %s to %s, %s", src, dst, errors) end end -- is directory? |
