super(lockfile);
// try and get a lock.
try {
- _lock = new File(lockfile.getParentFile(), lockfile.getName()+"."+_LockSuffix);
+ _lock = make_lockForTarget(lockfile);
if (!ensureLockFile(block)) {
log.debug("Couldn't get lock on "+_lock);
tidy();
+ lockfile.getAbsolutePath(),e);
}
}
-
+ /**
+ *
+ * @param lockfile target of lock
+ * @return file object that will be locked for lockfile
+ */
+ private File make_lockForTarget(File lockfile) {
+ return new File(lockfile.getParentFile(), lockfile.getName()+"."+_LockSuffix);
+ }
private boolean openRaFile() throws IOException {
if (target==null)
return false;
log.debug("Failed to getRaChannel on target "+target);
return null;
}
+ public boolean isTargetLockFile(File afile) {
+ if (isLocked())
+ {
+ if (target.equals(afile) || make_lockForTarget(target).equals(afile))
+ return true;
+ }
+ return false;
+ }
}
target = lockfile;
}
/**
+ * test whether the given file is a target or related to the lock
+ * on the target file.
+ * @param afile a file
+ * @return true if target is locked and afile is related to target
+ */
+ public abstract boolean isTargetLockFile(File afile);
+ /**
*
* @return true if lock is held on the target
*/