You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Jeremias Maerki <de...@greenmail.ch> on 2003/08/21 20:52:14 UTC

Re: cvs commit: jakarta-commons-sandbox/io/src/java/org/apache/commons/io FileUtils.java

I forgot to credit Alban Peignier <alban.peignier at free.fr> for his
isFileNewer methods. I'm sorry. I shouldn't do more than a couple of
things at once.
http://nagoya.apache.org/eyebrowse/BrowseList?listName=commons-dev@jakarta.apache.org&by=thread&from=348688

On 21.08.2003 20:40:48 jeremias wrote:
> jeremias    2003/08/21 11:40:48
> 
>   Modified:    io/src/java/org/apache/commons/io FileUtils.java

<snip/>

>   Index: FileUtils.java
>   ===================================================================
>   RCS file: /home/cvs/jakarta-commons-sandbox/io/src/java/org/apache/commons/io/FileUtils.java,v
>   retrieving revision 1.13
>   retrieving revision 1.14
>   diff -u -r1.13 -r1.14

<snip/>

>   +     /**
>   +      * Tests if the specified <code>File</code> is newer than the reference 
>   +      * <code>File</code>.
>   +      *
>   +      * @param file the <code>File</code> of which the modification date must be compared
>   +      * @param reference the <code>File</code> of which the modification date is used 
>   +      * like reference
>   +      * @return true if the <code>File</code> exists and has been modified more recently
>   +      * than the reference <code>File</code>.
>   +      */
>   +     public static boolean isFileNewer(final File file, final File reference) {
>   +         if (reference == null) {
>   +             throw new IllegalArgumentException("No specified reference file");
>   +         }
>   +         if (!reference.exists()) {
>   +             throw new IllegalArgumentException("The reference file '" + file + "' doesn't exist");
>   +         }
>   + 
>   +         return isFileNewer(file, reference.lastModified());
>   +     }
>   + 
>   +     /**
>   +      * Tests if the specified <code>File</code> is newer than the specified 
>   +      * <code>Date</code>
>   +      *
>   +      * @param file the <code>File</code> of which the modification date must be compared
>   +      * @param date the date reference
>   +      * @return true if the <code>File</code> exists and has been modified after
>   +      * the given <code>Date</code>.
>   +      */
>   +     public static boolean isFileNewer(final File file, final Date date) {
>   +         if (date == null) {
>   +             throw new IllegalArgumentException("No specified date");
>   +         }
>   +         return isFileNewer(file, date.getTime());
>   +     }
>   + 
>   +     /**
>   +      * Tests if the specified <code>File</code> is newer than the specified 
>   +      * time reference.
>   +      *
>   +      * @param file the <code>File</code> of which the modification date must be compared.
>   +      * @param timeMillis the time reference measured in milliseconds since the epoch 
>   +      * (00:00:00 GMT, January 1, 1970)
>   +      * @return true if the <code>File</code> exists and has been modified after
>   +      * the given time reference.
>   +      */
>   +     public static boolean isFileNewer(final File file, final long timeMillis) {
>   +         if (file == null) {
>   +             throw new IllegalArgumentException("No specified file");
>   +         }
>   +         if (!file.exists()) {
>   +             return false;
>   +         }
>   + 
>   +         return file.lastModified() > timeMillis;
>   +    }



Jeremias Maerki