You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by bo...@apache.org on 2009/08/25 10:11:44 UTC
svn commit: r807514 - in /commons/proper/compress/trunk/src:
changes/changes.xml
main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
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 @@
</properties>
<body>
<release version="1.1" date="as in SVN" description="Release 1.1">
+ <action type="add" date="2009-08-25">
+ 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.
+ </action>
<action issue="COMPRESS-83" type="fix" date="2009-08-01">
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