Skip to content
Snippets Groups Projects
Commit d90c5acd authored by brinn's avatar brinn
Browse files

change: lastChanged() and lastChangedRelative() now look for files younger...

change: lastChanged() and lastChangedRelative() now look for files younger than specified with stopWhenFindYounger (previous semantics was that files needed to be as young as or younger)

SVN: 4427
parent d78b7db9
No related branches found
No related tags found
No related merge requests found
...@@ -493,10 +493,10 @@ public final class FileUtilities ...@@ -493,10 +493,10 @@ public final class FileUtilities
{ {
if (referenceIsRelative) if (referenceIsRelative)
{ {
return reference > 0 && currentLastChanged >= System.currentTimeMillis() - reference; return reference > 0 && currentLastChanged > System.currentTimeMillis() - reference;
} else } else
{ {
return reference > 0 && currentLastChanged >= reference; return reference > 0 && currentLastChanged > reference;
} }
} }
...@@ -561,9 +561,9 @@ public final class FileUtilities ...@@ -561,9 +561,9 @@ public final class FileUtilities
* considering what this parameter is good for, note that the mtime of a directory is changed when an * considering what this parameter is good for, note that the mtime of a directory is changed when an
* entry in the directory changes. * entry in the directory changes.
* @param stopWhenFindYounger If > 0, the recursive search for younger file will be stopped when a file or * @param stopWhenFindYounger If > 0, the recursive search for younger file will be stopped when a file or
* directory is found that is as young as or younger than the time specified in this parameter. Supposed * directory is found that is younger than the time specified in this parameter. Supposed to be used when
* to be used when one does not care about the absolute youngest entry, but only, if there are entries * one does not care about the absolute youngest entry, but only, if there are entries that are "young
* that are "young enough". * enough".
* @return The time when any file in (or below) <var>path</var> has last been changed in the file system. * @return The time when any file in (or below) <var>path</var> has last been changed in the file system.
* @throws CheckedExceptionTunnel of an {@link IOException} if the <var>path</var> does not exist or is not * @throws CheckedExceptionTunnel of an {@link IOException} if the <var>path</var> does not exist or is not
* readable. * readable.
...@@ -585,7 +585,7 @@ public final class FileUtilities ...@@ -585,7 +585,7 @@ public final class FileUtilities
* considering what this parameter is good for, note that the mtime of a directory is changed when an * considering what this parameter is good for, note that the mtime of a directory is changed when an
* entry in the directory changes. * entry in the directory changes.
* @param stopWhenFindYoungerRelative If &gt; 0, the recursive search for younger file will be stopped when a file * @param stopWhenFindYoungerRelative If &gt; 0, the recursive search for younger file will be stopped when a file
* or directory is found that is as young as or younger than * or directory is found that is younger than
* <code>System.currentTimeMillis() - stopWhenYoungerRelative</code>. Supposed to be used when one * <code>System.currentTimeMillis() - stopWhenYoungerRelative</code>. Supposed to be used when one
* does not care about the absolute youngest entry, but only, if there are entries that are "young * does not care about the absolute youngest entry, but only, if there are entries that are "young
* enough". * enough".
...@@ -785,15 +785,15 @@ public final class FileUtilities ...@@ -785,15 +785,15 @@ public final class FileUtilities
"Failed to get listing of directory '%s' (path is file instead of directory).", directory)); "Failed to get listing of directory '%s' (path is file instead of directory).", directory));
} else } else
{ {
logger.log(LogLevel.ERROR, String.format( logger.log(LogLevel.ERROR, String.format("Failed to get listing of directory '%s' (path not found).",
"Failed to get listing of directory '%s' (path not found).", directory)); directory));
} }
} else } else
{ {
StringWriter exStackWriter = new StringWriter(); StringWriter exStackWriter = new StringWriter();
exOrNull.printStackTrace(new PrintWriter(exStackWriter)); exOrNull.printStackTrace(new PrintWriter(exStackWriter));
logger.log(LogLevel.ERROR, String.format( logger.log(LogLevel.ERROR, String.format("Failed to get listing of directory '%s'. Exception: %s",
"Failed to get listing of directory '%s'. Exception: %s", directory, exStackWriter.toString())); directory, exStackWriter.toString()));
} }
} }
......
...@@ -124,8 +124,8 @@ public class FileUtilitiesLastChangedTest ...@@ -124,8 +124,8 @@ public class FileUtilitiesLastChangedTest
dirA.setLastModified(1000L); dirA.setLastModified(1000L);
assertEquals(3000L, FileUtilities.lastChanged(dirA, false, 0L)); assertEquals(3000L, FileUtilities.lastChanged(dirA, false, 0L));
assertEquals(2000L, FileUtilities.lastChanged(dirA, true, 0L)); assertEquals(2000L, FileUtilities.lastChanged(dirA, true, 0L));
assertEquals(1000L, FileUtilities.lastChanged(dirA, false, 1000L)); assertEquals(1000L, FileUtilities.lastChanged(dirA, false, 999L));
assertEquals(1000L, FileUtilities.lastChanged(dirA, true, 1000L)); assertEquals(1000L, FileUtilities.lastChanged(dirA, true, 999L));
} }
@Test @Test
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment