ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ru...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs Tar.java
Date Sat, 10 Feb 2001 15:13:10 GMT
rubys       01/02/10 07:13:10

  Modified:    docs     index.html
               src/main/org/apache/tools/ant/taskdefs Tar.java
  Log:
  Add a warn on longfile mode
  ----------------------------------------------------------------------
  
  Revision  Changes    Path
  1.203     +9 -1      jakarta-ant/docs/index.html
  
  Index: index.html
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/docs/index.html,v
  retrieving revision 1.202
  retrieving revision 1.203
  diff -u -r1.202 -r1.203
  --- index.html	2001/02/04 13:08:52	1.202
  +++ index.html	2001/02/10 15:13:08	1.203
  @@ -34,7 +34,7 @@
   
   <center>
   <p>Version: @VERSION@<br>
  -$Id: index.html,v 1.202 2001/02/04 13:08:52 nico Exp $</p>
  +$Id: index.html,v 1.203 2001/02/10 15:13:08 rubys Exp $</p>
   </center>
   
   <hr>
  @@ -4952,6 +4952,14 @@
       <td valign="top">defaultexcludes</td>
       <td valign="top">indicates whether default excludes should be used or not
         (&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>
  
  
  
  1.11      +25 -12    jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Tar.java
  
  Index: Tar.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Tar.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- Tar.java	2001/02/04 13:58:16	1.10
  +++ Tar.java	2001/02/10 15:13:09	1.11
  @@ -70,13 +70,16 @@
   
   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 @@
        *
        * 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 @@
           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 @@
           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());
  
  
  

Mime
View raw message