ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From co...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs Tar.java
Date Tue, 13 Feb 2001 13:11:37 GMT
conor       01/02/13 05:11:37

  Modified:    src/main/org/apache/tools/ant/taskdefs Tar.java
  Log:
  Merge back Tar changes so they can be tested with Gump
  
  Revision  Changes    Path
  1.13      +45 -11    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.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- Tar.java	2001/02/13 12:31:58	1.12
  +++ Tar.java	2001/02/13 13:11:37	1.13
  @@ -75,7 +75,10 @@
       static public final String FAIL = "fail";
       static public final String TRUNCATE = "truncate";
       static public final String GNU = "gnu";
  +    static public final String OMIT = "omit";
   
  +    private String[] validModes = new String[] {WARN, FAIL, TRUNCATE, GNU, OMIT};
  +
       File tarFile;
       File baseDir;
       
  @@ -83,6 +86,11 @@
       
       Vector filesets = new Vector();
       Vector fileSetFiles = new Vector();
  +    
  +    /**
  +     * Indicates whether the user has been warned about long files already.
  +     */
  +    private boolean longWarningGiven = false;
   
       public TarFileSet createTarFileSet() {
           TarFileSet fileset = new TarFileSet();
  @@ -109,13 +117,20 @@
        * Set how to handle long files.
        *
        * Allowable values are
  -     *   truncate
  -     *   fail
  -     *   warn
  -     *   gnu
  +     *   truncate - paths are truncated to the maximum length
  +     *   fail - patsh greater than the maximim cause a build exception
  +     *   warn - paths greater than the maximum cause a warning and GNU is used
  +     *   gnu - GNU extensions are used for any paths greater than the maximum.
  +     *   omit - paths greater than the maximum are omitted from the archive
        */
       public void setLongfile(String mode) {
  -        this.longFileMode = mode;
  +        for (int i = 0; i < validModes.length; ++i) {
  +            if (mode.equalsIgnoreCase(validModes[i])) {
  +                this.longFileMode = mode;
  +                return;
  +            }
  +        }
  +        throw new BuildException("The longfile value " + mode + " is not a valid value");
       }
   
       public void execute() throws BuildException {
  @@ -145,7 +160,12 @@
               mainFileSet.setDefaultexcludes(useDefaultExcludes);
               filesets.addElement(mainFileSet);
           }
  -
  +        
  +        if (filesets.size() == 0) {
  +            throw new BuildException("You must supply either a basdir attribute or some
nested filesets.", 
  +                                     location);
  +        }
  +        
           // check if tr is out of date with respect to each
           // fileset
           boolean upToDate = true;
  @@ -171,8 +191,19 @@
           try {
               tOut = new TarOutputStream(new FileOutputStream(tarFile));
               tOut.setDebug(true);
  -            tOut.setLongFileMode(TarOutputStream.LONGFILE_GNU);
  +            if (longFileMode.equalsIgnoreCase(TRUNCATE)) {
  +                tOut.setLongFileMode(TarOutputStream.LONGFILE_TRUNCATE);
  +            }
  +            else if (longFileMode.equalsIgnoreCase(FAIL) ||
  +                     longFileMode.equalsIgnoreCase(OMIT)) {
  +                tOut.setLongFileMode(TarOutputStream.LONGFILE_ERROR);
  +            }
  +            else {
  +                // warn or GNU
  +                tOut.setLongFileMode(TarOutputStream.LONGFILE_GNU);
  +            }
           
  +            longWarningGiven = false;
               for (Enumeration e = filesets.elements(); e.hasMoreElements();) {
                   TarFileSet fs = (TarFileSet)e.nextElement();
                   String[] files = fs.getFiles(project);
  @@ -204,14 +235,17 @@
   
           try {
               if (vPath.length() >= TarConstants.NAMELEN) {
  -                if (longFileMode.equalsIgnoreCase(TRUNCATE)) {
  -                    log("Skipping: "+ vPath, Project.MSG_INFO);
  +                if (longFileMode.equalsIgnoreCase(OMIT)) {
  +                    log("Omitting: "+ 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);
  +                    if (!longWarningGiven) {                        
  +                        log("Resulting tar file can only be processed successfully"
  +                            + " by GNU compatible tar commands", Project.MSG_WARN);
  +                        longWarningGiven = true;
  +                    }
                   } else if (longFileMode.equalsIgnoreCase(FAIL)) {
                       throw new BuildException(
                           "Entry: "+ vPath + " longer than " + 
  
  
  

Mime
View raw message