Browse Source

Add drimode attribute for the permissions od directories to <tarfileset>.

PR: 12289


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@273555 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 22 years ago
parent
commit
98f3237b31
3 changed files with 40 additions and 7 deletions
  1. +3
    -0
      WHATSNEW
  2. +10
    -2
      docs/manual/CoreTasks/tar.html
  3. +27
    -5
      src/main/org/apache/tools/ant/taskdefs/Tar.java

+ 3
- 0
WHATSNEW View File

@@ -118,6 +118,9 @@ Other changes:
* <style> has a new attribute reuseloadedstylesheet to work around a
bug in widespread Xalan versions.

* <tarfileset> has a new dirmode attribute to specify the permissions
for directories.

Changes from Ant 1.5.1Beta1 to 1.5.1
====================================



+ 10
- 2
docs/manual/CoreTasks/tar.html View File

@@ -121,8 +121,16 @@ attributes
</tr>
<tr>
<td valign="top">mode</td>
<td valign="top">A 3 digit octal string, specify the user, group and other modes in
the standard Unix fashion</td>
<td valign="top">A 3 digit octal string, specify the user, group
and other modes in the standard Unix fashion. Only applies to
plain files. Default is 644.</td>
<td align="center" valign="top">No</td>
</tr>
<tr>
<td valign="top">dirmode</td>
<td valign="top">A 3 digit octal string, specify the user, group
and other modes in the standard Unix fashion. Only applies to
directories. Default is 755. <em>since Ant 1.6</em>.</td>
<td align="center" valign="top">No</td>
</tr>
<tr>


+ 27
- 5
src/main/org/apache/tools/ant/taskdefs/Tar.java View File

@@ -74,8 +74,7 @@ import org.apache.tools.bzip2.CBZip2OutputStream;
import org.apache.tools.tar.TarConstants;
import org.apache.tools.tar.TarEntry;
import org.apache.tools.tar.TarOutputStream;


import org.apache.tools.zip.UnixStat;

/**
* Creates a tar archive.
@@ -403,6 +402,8 @@ public class Tar extends MatchingTask {
if (!file.isDirectory()) {
te.setSize(file.length());
te.setMode(tarFileSet.getMode());
} else {
te.setMode(tarFileSet.getDirMode());
}
te.setUserName(tarFileSet.getUserName());
te.setGroupName(tarFileSet.getGroup());
@@ -441,7 +442,8 @@ public class Tar extends MatchingTask {
public static class TarFileSet extends FileSet {
private String[] files = null;

private int mode = 0100644;
private int fileMode = UnixStat.FILE_FLAG | UnixStat.DEFAULT_FILE_PERM;
private int dirMode = UnixStat.DIR_FLAG | UnixStat.DEFAULT_DIR_PERM;

private String userName = "";
private String groupName = "";
@@ -482,11 +484,31 @@ public class Tar extends MatchingTask {
* optional, default=0644
*/
public void setMode(String octalString) {
this.mode = 0100000 | Integer.parseInt(octalString, 8);
this.fileMode =
UnixStat.FILE_FLAG | Integer.parseInt(octalString, 8);
}

public int getMode() {
return mode;
return fileMode;
}

/**
* A 3 digit octal string, specify the user, group and
* other modes in the standard Unix fashion;
* optional, default=0755
*
* @since Ant 1.6
*/
public void setDirMode(String octalString) {
this.dirMode =
UnixStat.DIR_FLAG | Integer.parseInt(octalString, 8);
}

/**
* @since Ant 1.6
*/
public int getDirMode() {
return dirMode;
}

/**


Loading…
Cancel
Save