avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/io FileUtil.java
Date Sun, 17 Feb 2002 09:12:49 GMT
donaldp     02/02/17 01:12:48

  Modified:    src/java/org/apache/avalon/excalibur/io FileUtil.java
  Log:
  Add a forceMkdir
  
  Revision  Changes    Path
  1.20      +27 -1     jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/io/FileUtil.java
  
  Index: FileUtil.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/io/FileUtil.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- FileUtil.java	10 Feb 2002 09:02:04 -0000	1.19
  +++ FileUtil.java	17 Feb 2002 09:12:48 -0000	1.20
  @@ -45,7 +45,7 @@
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
    * @author <a href="mailto:jefft@apache.org">Jeff Turner</a>
  - * @version CVS $Revision: 1.19 $ $Date: 2002/02/10 09:02:04 $
  + * @version CVS $Revision: 1.20 $ $Date: 2002/02/17 09:12:48 $
    * @since 4.0
    */
   public final class FileUtil
  @@ -625,6 +625,32 @@
               if( false == file.delete() )
               {
                   final String message = "File " + file + " unable to be deleted.";
  +                throw new IOException( message );
  +            }
  +        }
  +    }
  +
  +    /**
  +     * Make a directory. If there already exists a file with specified name or
  +     * the directory is unable to be created then an exception is thrown.
  +     */
  +    public static void forceMkdir( final File file )
  +        throws IOException
  +    {
  +        if( file.exists() )
  +        {
  +            if( file.isFile() )
  +            {
  +                final String message = "File " + file + " exists and is " +
  +                    "not a directory. Unable to create directory.";
  +                throw new IOException( message );
  +            }
  +        }
  +        else
  +        {
  +            if( false == file.mkdirs() )
  +            {
  +                final String message = "Unable to create directory " + file;
                   throw new IOException( message );
               }
           }
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-cvs-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>


Mime
View raw message