*/
public synchronized void update() {
if (!directory.exists()) {
repositories = emptyRepositories;
if (resources == null) {
resources = new HashMap();
} else {
resources.clear();
}
lastModified = 0;
return;
}
if (directory.lastModified() != lastModified) {
lastModified = directory.lastModified();
File[] list = directory.listFiles();
ArrayList newRepositories = new ArrayList(list.length);
HashMap newResources = new HashMap(list.length);
for (int i = 0; i < list.length; i++) {
if (list[i].isDirectory()) {
// a nested directory aka child file repository
newRepositories.add(new FileRepository(list[i], this));
} else if (list[i].getName().endsWith(".zip")) {
// a nested zip repository
newRepositories.add(new ZipRepository(list[i], this));
} else if (list[i].isFile()) {
// a file resource
FileResource resource = new FileResource(list[i], this);
newResources.put(resource.getShortName(), resource);
}
}
repositories = (Repository[])
newRepositories.toArray(new Repository[newRepositories.size()]);