I'm trying to get a file lock across a mount point via Java 6 on OSX:
private void tryLockThroughShare() {
String path = "/Volumes/Groups/mcm/javaTestInShare.txt";
try {
RandomAccessFile raf = new RandomAccessFile(path, "rw");
FileLock flock = raf.getChannel().tryLock();
System.out.printf("File %s is %s\n", path, (flock != null) ?
("locked") : ("not locked")); raf.write("yoo hoo!".getBytes()); raf.close(); } catch (IOException e) { e.printStackTrace(); } }
When I mount a volume using either AFP or SMB, even though I can write files in the mounted destination, I cannot lock them, receiving instead: IOException (Operation not supported).
After some experimentation I found I could lock when the volume was setup using NFS.
Has anyone found a way to lock a file across a SMB or AFP mount?