Skip to content

Commit 32cabe0

Browse files
committed
add writeable for os.cp #5138
1 parent f612170 commit 32cabe0

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

core/src/xmake/os/cpfile.c

+4
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ tb_int_t xm_os_cpfile(lua_State* lua)
4949
if (is_symlink)
5050
flags |= TB_FILE_COPY_LINK;
5151

52+
tb_bool_t is_writeable = lua_toboolean(lua, 4);
53+
if (is_writeable)
54+
flags |= TB_FILE_COPY_WRITEABLE;
55+
5256
// do copy
5357
lua_pushboolean(lua, tb_file_copy(src, dst, flags));
5458
return 1;

xmake/actions/create/main.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ function _create_project(language, templateid, targetname)
9898
local sourcedir = path.join(tempinst:scriptdir(), "project")
9999
if os.isdir(sourcedir) then
100100
for _, filedir in ipairs(os.filedirs(path.join(sourcedir, "*"))) do
101-
os.cp(filedir, projectdir)
101+
os.cp(filedir, projectdir, {writeable = true})
102102
table.insert(filedirs, path.relative(filedir, sourcedir))
103103
end
104104
os.cp(path.join(os.programdir(), "scripts", "gitignore"), path.join(projectdir, ".gitignore"))

xmake/core/base/os.lua

+2-1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ function os._cp(src, dst, rootdir, opt)
7070

7171
-- is file or link?
7272
local symlink = opt.symlink
73+
local writeable = opt.writeable
7374
if os.isfile(src) or (symlink and os.islink(src)) then
7475

7576
-- the destination is directory? append the filename
@@ -85,7 +86,7 @@ function os._cp(src, dst, rootdir, opt)
8586
if opt.force and os.isfile(dst) then
8687
os.rmfile(dst)
8788
end
88-
if not os.cpfile(src, dst, symlink) then
89+
if not os.cpfile(src, dst, symlink, writeable) then
8990
local errors = os.strerror()
9091
if symlink and os.islink(src) then
9192
local reallink = os.readlink(src)

0 commit comments

Comments
 (0)