crafterm    2003/07/08 08:11:48

  Modified:    sourceresolve/src/java/org/apache/excalibur/source/impl
                        FileSource.java
  Log:
  Added fix for FileSource.moveTo() when moving the current
  FileSource to a new FileSource target that has non-existent
  parent directories.
  
  Revision  Changes    Path
  1.8       +10 -2     
avalon-excalibur/sourceresolve/src/java/org/apache/excalibur/source/impl/FileSource.java
  
  Index: FileSource.java
  ===================================================================
  RCS file: 
/home/cvs/avalon-excalibur/sourceresolve/src/java/org/apache/excalibur/source/impl/FileSource.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- FileSource.java   7 Jun 2003 18:29:17 -0000       1.7
  +++ FileSource.java   8 Jul 2003 15:11:47 -0000       1.8
  @@ -471,7 +471,15 @@
       {
           if (destination instanceof FileSource)
           {
  -            if (!m_file.renameTo(((FileSource) destination).getFile()))
  +            final File dest = ((FileSource) destination).getFile();
  +            final File parent = dest.getParentFile();
  +
  +            if (parent != null)
  +            {
  +                parent.mkdirs(); // ensure parent directories exist
  +            }
  +
  +            if (!m_file.renameTo(dest))
               {
                   throw new SourceException("Couldn't move " + getURI() + " to " + 
destination.getURI());
               }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to