1 19 20 package org.netbeans.modules.masterfs.filebasedfs.fileobjects; 21 22 import org.netbeans.modules.masterfs.filebasedfs.utils.FSException; 23 import org.openide.filesystems.FileLock; 24 25 import java.io.File ; 26 import java.io.IOException ; 27 28 31 public final class WriteLockFactory { 32 public static synchronized FileLock tryLock(final File file, boolean lightWeight) throws IOException { 33 boolean isLockFile = WriteLockUtils.hasActiveLockFileSigns(file.getAbsolutePath()); 34 if (isLockFile) { 35 IOException toFire = new IOException (file.getAbsolutePath()); 36 FSException.annotateException(toFire); 37 throw toFire; 38 } 39 40 return (lightWeight) ? WriteLock.tryLightWeightLock(file) : 41 ((isNioLockingEnabled()) ? WriteLock.tryNioLock(file) : WriteLock.tryLock(file)); 42 } 43 44 private static boolean isNioLockingEnabled() { 45 return false; 47 } 48 49 private WriteLockFactory(){} 50 } 51 | Popular Tags |