This patch is to add a dirMode attribute to tarfileset element in tar task, so that the modes of directories selected by the tarfileset will be set to the customized values.

Patches is attached.

_________________________________________________________________
Find gifts, buy online with MSN Shopping. http://shopping.msn.com.sg/
--- apache-ant-1.5.3-1/src/main/org/apache/tools/ant/taskdefs/Tar.java 2003-04-16 17:28:22.000000000 +0800
+++ Tar.java 2003-07-15 11:09:15.000000000 +0800
@@ -403,6 +403,10 @@
if (!file.isDirectory()) {
te.setSize(file.length());
te.setMode(tarFileSet.getMode());
+ } else if (tarFileSet.getDirMode() >= 0) {
+ // If directory mode is set explicitly,
+ // follow user's requirement
+ te.setMode(tarFileSet.getDirMode());
}
te.setUserName(tarFileSet.getUserName());
te.setGroupName(tarFileSet.getGroup());
@@ -452,6 +456,7 @@
private String[] files = null;


        private int mode = 0100644;
+        private int dirMode = -1;

        private String userName = "";
        private String groupName = "";
@@ -500,6 +505,34 @@
        }

        /**
+         * Set the mode for directories selected by this tar file set.
+         * <p>
+         * This is to address the needs of setting permissions of
+         * directories in tar file. It is fine to assume a world readable
+         * and accessable permission, i.e., 755 for most projects; how
+         * ever for certain project it is more desirable to restrict
+         * the permissions for certain directory.
+         * </p>
+         *
+         * <p>
+         * If user specified dirMode attribute of tarfileset element,
+         * all directories included in that file set will be set to
+         * the specified mode.
+         * </p>
+         *
+         * @param octalString A 3 digit octal string, specify the user,
+         *        group and other modes in the standard Unix fashion for
+         *        directories; optional, default not set.
+         */
+        public void setDirMode(String octalString) {
+            this.dirMode = 0100000 | Integer.parseInt(octalString, 8);
+        }
+
+        public int getDirMode() {
+            return dirMode;
+        }
+
+        /**
         * The username for the tar entry
         * This is not the same as the UID, which is
         * not currently set by the task.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to