Return-Path: Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: (qmail 76697 invoked from network); 25 Aug 2009 08:11:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 25 Aug 2009 08:11:47 -0000 Received: (qmail 66239 invoked by uid 500); 25 Aug 2009 08:12:12 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 66155 invoked by uid 500); 25 Aug 2009 08:12:12 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 66146 invoked by uid 99); 25 Aug 2009 08:12:11 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Aug 2009 08:12:11 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Aug 2009 08:12:05 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id DD4E623888E4; Tue, 25 Aug 2009 08:11:44 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r807514 - in /commons/proper/compress/trunk/src: changes/changes.xml main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java Date: Tue, 25 Aug 2009 08:11:44 -0000 To: commits@commons.apache.org From: bodewig@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090825081144.DD4E623888E4@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: bodewig Date: Tue Aug 25 08:11:44 2009 New Revision: 807514 URL: http://svn.apache.org/viewvc?rev=807514&view=rev Log: The tar Ant task has a usecase where absolute paths inside archives are required - allow creation of such entries Modified: commons/proper/compress/trunk/src/changes/changes.xml commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java (contents, props changed) Modified: commons/proper/compress/trunk/src/changes/changes.xml URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/changes/changes.xml?rev=807514&r1=807513&r2=807514&view=diff ============================================================================== --- commons/proper/compress/trunk/src/changes/changes.xml (original) +++ commons/proper/compress/trunk/src/changes/changes.xml Tue Aug 25 08:11:44 2009 @@ -23,6 +23,11 @@ + + A new constructor of TarArchiveEntry can create entries with + names that start with slashes - the default is to strip + leading slashes in order to create relative path names. + Delegate all read and write methods in GZip stream in order to speed up operations. Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java?rev=807514&r1=807513&r2=807514&view=diff ============================================================================== --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java (original) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java Tue Aug 25 08:11:44 2009 @@ -167,9 +167,21 @@ * @param name the entry name */ public TarArchiveEntry(String name) { + this(name, false); + } + + /** + * Construct an entry with only a name. This allows the programmer + * to construct the entry's header "by hand". File is set to null. + * + * @param name the entry name + * @param preserveLeadingSlashes whether to allow leading slashes + * in the name. + */ + public TarArchiveEntry(String name, boolean preserveLeadingSlashes) { this(); - name = normalizeFileName(name); + name = normalizeFileName(name, preserveLeadingSlashes); boolean isDir = name.endsWith("/"); this.devMajor = 0; @@ -208,7 +220,7 @@ * @param file The file that the entry represents. */ public TarArchiveEntry(File file) { - this(file, normalizeFileName(file.getPath())); + this(file, normalizeFileName(file.getPath(), false)); } /** @@ -320,7 +332,7 @@ * @param name This entry's new name. */ public void setName(String name) { - this.name = normalizeFileName(name); + this.name = normalizeFileName(name, false); } /** @@ -642,7 +654,8 @@ * Strips Windows' drive letter as well as any leading slashes, * turns path separators into forward slahes. */ - private static String normalizeFileName(String fileName) { + private static String normalizeFileName(String fileName, + boolean preserveLeadingSlashes) { String osname = System.getProperty("os.name").toLowerCase(Locale.US); if (osname != null) { @@ -674,7 +687,7 @@ // No absolute pathnames // Windows (and Posix?) paths can start with "\\NetworkDrive\", // so we loop on starting /'s. - while (fileName.startsWith("/")) { + while (!preserveLeadingSlashes && fileName.startsWith("/")) { fileName = fileName.substring(1); } return fileName; Propchange: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java ------------------------------------------------------------------------------ --- svn:mergeinfo (added) +++ svn:mergeinfo Tue Aug 25 08:11:44 2009 @@ -0,0 +1,2 @@ +/ant/core/trunk/src/main/org/apache/tools/tar/TarArchiveEntry.java:741089 +/ant/core/trunk/src/main/org/apache/tools/tar/TarEntry.java:807513