commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jerem...@apache.org
Subject cvs commit: jakarta-commons/io/src/java/org/apache/commons/io FileUtils.java
Date Thu, 15 Jul 2004 09:16:17 GMT
jeremias    2004/07/15 02:16:17

  Modified:    io/src/java/org/apache/commons/io FileUtils.java
  Log:
  Bugfix for listFiles for directories where the current user has no rights.
  
  Reestablish JDK 1.3 compatibility for touch().
  
  Revision  Changes    Path
  1.35      +11 -7     jakarta-commons/io/src/java/org/apache/commons/io/FileUtils.java
  
  Index: FileUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/io/src/java/org/apache/commons/io/FileUtils.java,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- FileUtils.java	15 Jul 2004 08:21:14 -0000	1.34
  +++ FileUtils.java	15 Jul 2004 09:16:17 -0000	1.35
  @@ -121,19 +121,23 @@
        * @throws IOException If an I/O problem occurs
        */
       public static void touch(File file) throws IOException {
  -        OutputStream out = new FileOutputStream(file, true);
  -        IOUtils.closeQuietly(out);
  +        if (!file.exists()) {
  +            OutputStream out = new FileOutputStream(file);
  +            IOUtils.closeQuietly(out);
  +        }
           file.setLastModified(System.currentTimeMillis());
       }
   
   
       private static void innerListFiles(Collection files, File directory, IOFileFilter filter)
{
           File[] found = directory.listFiles((FileFilter)filter);
  -        for (int i = 0; i < found.length; i++) {
  -            if (found[i].isDirectory()) {
  -                innerListFiles(files, found[i], filter);
  -            } else {
  -                files.add(found[i]);
  +        if (found != null) { 
  +            for (int i = 0; i < found.length; i++) {
  +                if (found[i].isDirectory()) {
  +                    innerListFiles(files, found[i], filter);
  +                } else {
  +                    files.add(found[i]);
  +                }
               }
           }
       }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message