/** overriden */ public void close() throws IOException { flock.releaseLock(); super.close(); } }
private void releaseLockForDelegates() { Iterator it = map.values().iterator(); while (it.hasNext()) { FileLock l = (FileLock) it.next(); l.releaseLock(); } map.clear(); }
/** Releases lock for old file object and * takes new one from newFo */ public void changeLocks(FileObject old, FileObject n) throws IOException { FileLock l = map.remove(old); if (l != null) { l.releaseLock(); } addLock(n); }
@Override public void close() throws IOException { try { super.flush(); lock.releaseLock(); super.close(); } catch(IOException iex) { if (lock.isValid()) { lock.releaseLock(); } throw iex; } } };
/** Finalize this object. Calls {@link #releaseLock} to release the lock if the program * for some reason failed to. */ @Override public void finalize() { if(isValid()) { releaseLock(); boolean assertOn = false; assert assertOn = true; if (assertOn) { StreamPool.LOG.log(Level.SEVERE, "Not released lock for file: " + toString() + " (trapped in finalizer)", lockedBy); // NOI18N } } } }
/** * Test if file is locked * @return true if file is locked * @since 7.3 */ public boolean isLocked() { FileLock fLock = null; try { fLock = lock(); } catch (FileAlreadyLockedException fax) { return true; } catch (IOException ex) { return false; } finally { if (fLock != null) { fLock.releaseLock(); } } return fLock == null; }
public void releaseLock() { if (this.isValid()) { super.releaseLock(); unlock(this); } } }
/** Delete this file. If the file is a folder and it is not empty then * all of its contents are also recursively deleted. FileObject is locked * before delete and finally is this lock released. * * @exception IOException if the file could not be deleted or * FileAlreadyLockedException if the file is already locked {@link #lock} * @since 1.15 */ public final void delete() throws IOException { FileLock lock = lock(); try { delete(lock); } finally { lock.releaseLock(); } }
public void releaseLock() { if (this.isValid()) { super.releaseLock(); releaseLockForDelegates(); if (getCurrentMfLock() == this) { // clears the reference to this lock from the file object MultiFileObject.this.lock = null; } } }
/** Deletes a file object that will mask the given file. * @param fs filesystem to work on * @param res resource name of the file * @exception IOException if it fails */ void unmaskFile(FileSystem fs, String res) throws IOException { FileObject fo = findResourceOn(fs, res + MASK); if (fo != null) { FileLock lock = fo.lock(); try { fo.delete(lock); } finally { lock.releaseLock(); } } }
/** Moves file to the selected folder. * This implementation uses a copy-and-delete mechanism, and automatically uses the necessary lock. * @param source source file object * @param destFolder destination folder * @param newName file name (without extension) of destination file * @return new file object * @exception IOException if either the {@link #copyFile copy} or {@link FileObject#delete delete} failed */ public static FileObject moveFile(FileObject source, FileObject destFolder, String newName) throws IOException { FileLock lock = null; try { lock = source.lock(); return source.move(lock, destFolder, newName, source.getExt()); } finally { if (lock != null) { lock.releaseLock(); } } }
} catch(IOException iex) { if (lock.isValid()) { lock.releaseLock();
final public void delete(FileLock lock) throws IOException { if (isFolder()) { FileObject[] fos = this.getChildren(); for (int i = 0; i < fos.length; i++) { FileObject fo = fos[i]; FileLock foLock = fo.lock(); try { fo.delete(foLock); } catch (IOException iex) { String message = NbBundle.getMessage(AbstractFolder.class, "EXC_CannotDelete", // XXX use FileUtil.getFileDisplayName instead? getPath(), fo.getFileSystem().getDisplayName() ); ExternalUtil.annotate(iex, message); //NOI18N throw iex; } finally { foLock.releaseLock(); } } } handleDelete(lock); }
public @Override void close() throws IOException { try { this.delegate.close(); } finally { this.lock.releaseLock(); synchronized (SourceFileObject.this) { text = null; } } } }
private void releaseLockForDelegates() { Iterator it = map.values().iterator(); while (it.hasNext()) { FileLock l = (FileLock)it.next (); l.releaseLock (); } map.clear (); }
public @Override void close() throws IOException { try { this.delegate.close(); } finally { this.lock.releaseLock(); resetCaches(); } } }
/** Finalize this object. Calls {@link #releaseLock} to release the lock if the program * for some reason failed to. */ public void finalize () { assert (isValid ()) : assertMessageForInvalidLocks(); releaseLock (); }
public FileObject rename (String name) throws IOException { boolean locked = isLocked (); FileLock lock = takeLock(); try { getFile().rename(lock, name, getFile().getExt()); } finally { if (!locked) lock.releaseLock(); } return getFile (); }