You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Niall Pemberton <ni...@gmail.com> on 2010/03/07 12:55:59 UTC

Re: svn commit: r919684 - in /commons/proper/io/trunk/src: java/org/apache/commons/io/FileUtils.java test/org/apache/commons/io/FileUtilsTestCase.java

As per comments on the JIRA ticket nothing has changed since this was
reverted - so -1 from me

Niall

On Sat, Mar 6, 2010 at 1:39 AM,  <se...@apache.org> wrote:
> 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
>
>
>

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