Browse Source

Add a warn on longfile mode

----------------------------------------------------------------------


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268627 13f79535-47bb-0310-9956-ffa450edef68
master
Sam Ruby 24 years ago
parent
commit
867ec77b0d
2 changed files with 33 additions and 12 deletions
  1. +8
    -0
      docs/index.html
  2. +25
    -12
      src/main/org/apache/tools/ant/taskdefs/Tar.java

+ 8
- 0
docs/index.html View File

@@ -4954,6 +4954,14 @@ task to come up with a .tar.gz package.</p>
(&quot;yes&quot;/&quot;no&quot;). Default excludes are used when omitted.</td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">longfile</td>
<td valign="top">One of <i>truncate</i>, <i>fail</i>, <i>warn</i>,
<i>gnu</i>. Determines how long files (&gt;100 chars) are to be handled.
Early versions did not support such names, and modern versions do so in
incompatible ways. Default is <i>warn</i>.
<td valign="top" align="center">No</td>
</tr>
</table>
<h3>Examples</h3>
<pre> &lt;tar tarfile=&quot;${dist}/manual.tar&quot; basedir=&quot;htdocs/manual&quot;/&gt;


+ 25
- 12
src/main/org/apache/tools/ant/taskdefs/Tar.java View File

@@ -70,13 +70,16 @@ import org.apache.tools.ant.types.*;

public class Tar extends MatchingTask {

// permissable values for longfile attribute
static public final String WARN = "warn";
static public final String FAIL = "fail";
static public final String TRUNCATE = "truncate";
static public final String GNU = "gnu";

File tarFile;
File baseDir;
String longFileMode = null;
String longFileMode = WARN;
Vector filesets = new Vector();
Vector fileSetFiles = new Vector();
@@ -107,10 +110,12 @@ public class Tar extends MatchingTask {
*
* Allowable values are
* truncate
* fail
* warn
* gnu
*/
public void setLongfile(String method) {
this.longFileMode = method;
public void setLongfile(String mode) {
this.longFileMode = mode;
}

public void execute() throws BuildException {
@@ -156,15 +161,7 @@ public class Tar extends MatchingTask {
try {
tOut = new TarOutputStream(new FileOutputStream(tarFile));
tOut.setDebug(true);
if (longFileMode == null) {
tOut.setLongFileMode(TarOutputStream.LONGFILE_ERROR);
}
else if (longFileMode.equalsIgnoreCase(TRUNCATE)) {
tOut.setLongFileMode(TarOutputStream.LONGFILE_TRUNCATE);
}
else if (longFileMode.equalsIgnoreCase(GNU)) {
tOut.setLongFileMode(TarOutputStream.LONGFILE_GNU);
}
tOut.setLongFileMode(TarOutputStream.LONGFILE_GNU);
for (Enumeration e = filesets.elements(); e.hasMoreElements();) {
TarFileSet fs = (TarFileSet)e.nextElement();
@@ -196,6 +193,22 @@ public class Tar extends MatchingTask {
FileInputStream fIn = new FileInputStream(file);

try {
if (vPath.length() >= TarConstants.NAMELEN) {
if (longFileMode.equalsIgnoreCase(TRUNCATE)) {
log("Skipping: "+ vPath, Project.MSG_INFO);
return;
} else if (longFileMode.equalsIgnoreCase(WARN)) {
log("Entry: "+ vPath + " longer than " +
TarConstants.NAMELEN + " characters.", Project.MSG_WARN);
log("Resulting tar file can only be processed successfully"
+ " by GNU compatible tar commands", Project.MSG_WARN);
} else if (longFileMode.equalsIgnoreCase(FAIL)) {
throw new BuildException(
"Entry: "+ vPath + " longer than " +
TarConstants.NAMELEN + "characters.", location);
}
}

TarEntry te = new TarEntry(vPath);
te.setSize(file.length());
te.setModTime(file.lastModified());


Loading…
Cancel
Save