tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dun...@hyperreal.org
Subject cvs commit: jakarta-tools/ant/src/main/org/apache/tools/ant/taskdefs Deltree.java
Date Tue, 02 Nov 1999 07:19:59 GMT
duncan      99/11/01 23:19:59

  Modified:    .        ant.jar
               ant/src/main/org/apache/tools/ant/taskdefs Deltree.java
  Log:
  Updated deltree task to not follow symlinks.
  
  Submitted by: Jay Doane
  Reviewed by: duncan
  
  Revision  Changes    Path
  1.13      +18 -18    jakarta-tools/ant.jar
  
  	<<Binary file>>
  
  
  1.2       +26 -16    jakarta-tools/ant/src/main/org/apache/tools/ant/taskdefs/Deltree.java
  
  Index: Deltree.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tools/ant/src/main/org/apache/tools/ant/taskdefs/Deltree.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Deltree.java	1999/10/09 00:06:07	1.1
  +++ Deltree.java	1999/11/02 07:19:58	1.2
  @@ -26,24 +26,34 @@
   		    " is not a dir";
   		throw new BuildException(msg);
   	    }
  -	    removeDir(dir);
  -	}
  +            try {
  +                removeDir(dir);
  +            } catch (IOException ioe) {
  +                String msg = "Unable to delete " + dir.getAbsolutePath();
  +                throw new BuildException(msg);
  +            }
  +        }
       }
  -
       
  -    private void removeDir(File dir) {
  -	String[] list = dir.list();
  -	for (int i = 0; i < list.length; i++) {
  -	    String s = list[i];
  -	    File f = new File(dir, s);
  -	    if (f.isDirectory()) {
  -		removeDir(f);
  -	    } else {
  -		f.delete();
  -	    }
  -	}
  -	dir.delete();
  -    }
  +    private void removeDir(File dir) throws IOException {
   
  +        // check to make sure that the given dir isn't a symlink
  +        // the comparison of absolute path and canonical path
  +        // catches this
  +        
  +        if (dir.getCanonicalPath().equals(dir.getAbsolutePath())) {
  +            String[] list = dir.list();
  +            for (int i = 0; i < list.length; i++) {
  +                String s = list[i];
  +                File f = new File(dir, s);
  +                if (f.isDirectory()) {
  +                    removeDir(f);
  +                } else {
  +                    f.delete();
  +                }
  +            }
  +        }
  +        dir.delete();
  +    }
   }
   
  
  
  

Mime
View raw message