in fam/src/main/java/org/apache/commons/jci2/fam/monitor/FilesystemAlterationObserverImpl.java [166:227]
public boolean needsToBeDeleted() {
if (!file.exists()) {
// deleted or has never existed yet
// log.debug(file + " does not exist or has been deleted");
deleteChildrenAndNotify();
// mark to be deleted by parent
return true;
}
// exists
final long currentModified = file.lastModified();
if (currentModified != lastModified) {
// last modified has changed
lastModified = currentModified;
// log.debug(file + " has new last modified");
// types only changes when also the last modified changes
final int newType = file.isDirectory()?TYPE_DIRECTORY:TYPE_FILE;
if (lastType != newType) {
// the type has changed
// log.debug(file + " has a new type");
deleteChildrenAndNotify();
lastType = newType;
// and then an add as the new type
if (newType == TYPE_DIRECTORY) {
notifyOnDirectoryCreate(this);
compareChildren();
} else {
notifyOnFileCreate(this);
}
return false;
}
if (newType == TYPE_DIRECTORY) {
notifyOnDirectoryChange(this);
compareChildren();
} else {
notifyOnFileChange(this);
}
} else {
// so exists and has not changed
// log.debug(file + " does exist and has not changed");
compareChildren();
}
return false;
}