commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r919684 - in /commons/proper/io/trunk/src: java/org/apache/commons/io/FileUtils.java test/org/apache/commons/io/FileUtilsTestCase.java
Date Sat, 06 Mar 2010 01:39:29 GMT
Author: sebb
Date: Sat Mar  6 01:39:28 2010
New Revision: 919684

URL: http://svn.apache.org/viewvc?rev=919684&view=rev
Log:
IO-157 FileUtils - Return target File from copyFileToDirectory() - thanks to Kenny MacLeod
(Reapplied)

Modified:
    commons/proper/io/trunk/src/java/org/apache/commons/io/FileUtils.java
    commons/proper/io/trunk/src/test/org/apache/commons/io/FileUtilsTestCase.java

Modified: commons/proper/io/trunk/src/java/org/apache/commons/io/FileUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/java/org/apache/commons/io/FileUtils.java?rev=919684&r1=919683&r2=919684&view=diff
==============================================================================
--- commons/proper/io/trunk/src/java/org/apache/commons/io/FileUtils.java (original)
+++ commons/proper/io/trunk/src/java/org/apache/commons/io/FileUtils.java Sat Mar  6 01:39:28
2010
@@ -560,14 +560,15 @@
      *
      * @param srcFile  an existing file to copy, must not be <code>null</code>
      * @param destDir  the directory to place the copy in, must not be <code>null</code>
+     * @return the new file
      *
      * @throws NullPointerException if source or destination is null
      * @throws IOException if source or destination is invalid
      * @throws IOException if an IO error occurs during copying
      * @see #copyFile(File, File, boolean)
      */
-    public static void copyFileToDirectory(File srcFile, File destDir) throws IOException
{
-        copyFileToDirectory(srcFile, destDir, true);
+    public static File copyFileToDirectory(File srcFile, File destDir) throws IOException
{
+        return copyFileToDirectory(srcFile, destDir, true);
     }
 
     /**
@@ -582,6 +583,7 @@
      * @param destDir  the directory to place the copy in, must not be <code>null</code>
      * @param preserveFileDate  true if the file date of the copy
      *  should be the same as the original
+     * @return the new file
      *
      * @throws NullPointerException if source or destination is <code>null</code>
      * @throws IOException if source or destination is invalid
@@ -589,7 +591,7 @@
      * @see #copyFile(File, File, boolean)
      * @since Commons IO 1.3
      */
-    public static void copyFileToDirectory(File srcFile, File destDir, boolean preserveFileDate)
throws IOException {
+    public static File copyFileToDirectory(File srcFile, File destDir, boolean preserveFileDate)
throws IOException {
         if (destDir == null) {
             throw new NullPointerException("Destination must not be null");
         }
@@ -598,6 +600,7 @@
         }
         File destFile = new File(destDir, srcFile.getName());
         copyFile(srcFile, destFile, preserveFileDate);
+        return destFile;
     }
 
     /**

Modified: commons/proper/io/trunk/src/test/org/apache/commons/io/FileUtilsTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/org/apache/commons/io/FileUtilsTestCase.java?rev=919684&r1=919683&r2=919684&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/org/apache/commons/io/FileUtilsTestCase.java (original)
+++ commons/proper/io/trunk/src/test/org/apache/commons/io/FileUtilsTestCase.java Sat Mar
 6 01:39:28 2010
@@ -903,7 +903,8 @@
         //This is to slow things down so we can catch if 
         //the lastModified date is not ok
         
-        FileUtils.copyFileToDirectory(testFile1, directory);
+        File result = FileUtils.copyFileToDirectory(testFile1, directory);
+        assertEquals("Check File", destination, result);
         assertTrue("Check Exist", destination.exists());
         assertTrue("Check Full copy", destination.length() == testFile1Size);
         /* disabled: Thread.sleep doesn't work reliantly for this case



Mime
View raw message