Tôi biết rằng tôi có thể <exec executable="cp" failonerror="true">
, tuy nhiên, tôi thực sự muốn có một nhiệm vụ mà tôi có thể gọi từ bất kỳ hệ điều hành nào có thể sử dụng tất cả (hoặc ít nhất là hầu hết) của các thuộc tính cho copy
, nhưng không hút các quyền trên unix.Có nhiệm vụ kiến nào có thể sao chép mà không bị mất quyền
Tôi tự hỏi liệu đã có giải pháp nào chưa, hoặc tôi sẽ phải tự viết copy2
của riêng mình.
Như tôi đã lo sợ, không có gì "ngoài giá". Chúng tôi có mã này, nhưng nó chỉ xử lý thư mục để sao chép thư mục hoặc tập tin để sao chép tập tin, có thuộc tính tùy chỉnh, và không làm bất kỳ điều gì khác gọn gàng sao chép nào.
<!-- ==================================================================== -->
<!-- Copy files from A to B -->
<!-- <copy> would do this job, if it weren't such a useless pile of fail -->
<!-- and could manage to preserve execute bits on Linux -->
<!-- ==================================================================== -->
<macrodef name="internal-copydir">
<attribute name="fromdir" default="NOT SET" />
<attribute name="todir" default="NOT SET" />
<sequential>
<if>
<os family="windows" />
<then>
<copy todir="@{todir}">
<fileset dir="@{fromdir}" />
</copy>
</then>
<else>
<exec executable="rsync" failonerror="true">
<arg value="-a" />
<arg value="@{fromdir}/" />
<arg value="@{todir}/" />
</exec>
</else>
</if>
</sequential>
</macrodef>
<!-- ==================================================================== -->
<!-- Copy file from A to B -->
<!-- <copy> would do this job, if it weren't such a useless pile of fail -->
<!-- and could manage to preserve execute bits on Linux -->
<!-- ==================================================================== -->
<macrodef name="internal-copyfile">
<attribute name="file" default="NOT SET" />
<attribute name="tofile" default="NOT SET" />
<sequential>
<if>
<os family="windows" />
<then>
<copy file="@{file}" tofile="@{tofile}"/>
</then>
<else>
<exec executable="cp" failonerror="true">
<arg value="@{file}" />
<arg value="@{tofile}" />
</exec>
</else>
</if>
</sequential>
</macrodef>
Tôi cũng đã viết cuốn sách này.
<!-- ==================================================================== -->
<!-- Copy file to a directory -->
<!-- <copy> would do this job, if it weren't such a useless pile of fail -->
<!-- and could manage to preserve execute bits on Linux -->
<!-- ==================================================================== -->
<macrodef name="internal-copyfiletodir">
<attribute name="file" default="NOT SET" />
<attribute name="todir" default="NOT SET" />
<sequential>
<if>
<os family="windows" />
<then>
<copy file="@{file}" todir="@{todir}"/>
</then>
<else>
<exec executable="cp" failonerror="true">
<arg value="@{file}" />
<arg value="@{todir}/" />
</exec>
</else>
</if>
</sequential>
</macrodef>