@Test public void testGetLastModified() throws InterruptedException { File f = new File("export" + File.separator + "jars" + File.separator); long date1 = FileSystemRepository.getLastModified(f, true); assertTrue(date1 > 0); Thread.sleep(2000); new File("export" + File.separator + "jars" + File.separator + "i5.las2peer.classLoaders.testPackage1-1.0.jar") .setLastModified(System.currentTimeMillis()); long date2 = FileSystemRepository.getLastModified(f, true); assertTrue(date1 < date2); long date3 = FileSystemRepository.getLastModified(f, true); assertTrue(date2 == date3); }
public static long getLastModified(File dir, boolean recursive) { File[] files = dir.listFiles(); if (files == null || files.length == 0) { return dir.lastModified(); } long lastModified = 0; for (File f : files) { if (f.isDirectory() && recursive) { long ll = getLastModified(f, recursive); if (lastModified < ll) { lastModified = ll; } } else { if (lastModified < f.lastModified()) { lastModified = f.lastModified(); } } } return lastModified; }
FileSystemRepository implements Repository { public static long getLastModified(File dir, boolean recursive) { File[] files = dir.listFiles(); if (files == null || files.length == 0) { return dir.lastModified(); } long lastModified = 0; for (File f : files) { if (f.isDirectory() && recursive) { long ll = getLastModified(f, recursive); if (lastModified < ll) { lastModified = ll; } } else { if (lastModified < f.lastModified()) { lastModified = f.lastModified(); } } } return lastModified; } }
FileSystemRepository implements Repository { public static long getLastModified(File dir, boolean recursive) { File[] files = dir.listFiles(); if (files == null || files.length == 0) { return dir.lastModified(); } long lastModified = 0; for (File f : files) { if (f.isDirectory() && recursive) { long ll = getLastModified(f, recursive); if (lastModified < ll) { lastModified = ll; } } else { if (lastModified < f.lastModified()) { lastModified = f.lastModified(); } } } return lastModified; } FileSystemRepository(String directory);  FileSystemRepository(String directory, boolean recursive);  FileSystemRepository(String[] directories);  FileSystemRepository(String[] directories, boolean recursive);  FileSystemRepository(Iterable<String> directories, boolean recursive); }
FileSystemRepository implements Repository { public static long getLastModified(File dir, boolean recursive) { File[] files = dir.listFiles(); if (files == null || files.length == 0) { return dir.lastModified(); } long lastModified = 0; for (File f : files) { if (f.isDirectory() && recursive) { long ll = getLastModified(f, recursive); if (lastModified < ll) { lastModified = ll; } } else { if (lastModified < f.lastModified()) { lastModified = f.lastModified(); } } } return lastModified; } FileSystemRepository(String directory);  FileSystemRepository(String directory, boolean recursive);  FileSystemRepository(String[] directories);  FileSystemRepository(String[] directories, boolean recursive);  FileSystemRepository(Iterable<String> directories, boolean recursive); @Override LoadedLibrary findLibrary(String name); @Override LoadedLibrary findLibrary(LibraryIdentifier lib); String[] getAvailableVersions(String libraryName); Collection<LibraryVersion> getAvailableVersionSet(String libraryName); String[] getAllLibraries(); Collection<String> getLibraryCollection(); static long getLastModified(File dir, boolean recursive); @Override String toString(); }
FileSystemRepository implements Repository { public static long getLastModified(File dir, boolean recursive) { File[] files = dir.listFiles(); if (files == null || files.length == 0) { return dir.lastModified(); } long lastModified = 0; for (File f : files) { if (f.isDirectory() && recursive) { long ll = getLastModified(f, recursive); if (lastModified < ll) { lastModified = ll; } } else { if (lastModified < f.lastModified()) { lastModified = f.lastModified(); } } } return lastModified; } FileSystemRepository(String directory);  FileSystemRepository(String directory, boolean recursive);  FileSystemRepository(String[] directories);  FileSystemRepository(String[] directories, boolean recursive);  FileSystemRepository(Iterable<String> directories, boolean recursive); @Override LoadedLibrary findLibrary(String name); @Override LoadedLibrary findLibrary(LibraryIdentifier lib); String[] getAvailableVersions(String libraryName); Collection<LibraryVersion> getAvailableVersionSet(String libraryName); String[] getAllLibraries(); Collection<String> getLibraryCollection(); static long getLastModified(File dir, boolean recursive); @Override String toString();  }