/** All next methods are private (Not visible outside this class)*/ private static StreamPool get(FileObject fo) { StreamPool strPool = fo2StreamPool.get(fo); if (strPool == null) { fo2StreamPool.put(fo, strPool = new StreamPool()); } return strPool; }
@Override public void write(int b) throws IOException { FileAlreadyLockedException alreadyLockedEx = new FileAlreadyLockedException(fo.getPath()); get(fo).annotate(alreadyLockedEx); throw alreadyLockedEx; } };
/** Get input stream. * @return an input stream to read the contents of this file * @exception FileNotFoundException if the file does not exists, is a folder * rather than a regular file or is invalid */ public InputStream getInputStream() throws FileNotFoundException { return StreamPool.createInputStream(this); }
private static void closeInputStream(AbstractFolder fo, InputStream is) { StreamPool foPool = find(fo); StreamPool fsPool = find(fo.getFileSystem()); Set foSet = (foPool != null) ? foPool.iStreams : null; Set fsSet = (fsPool != null) ? fsPool.iStreams : null; removeStreams(fsSet, foSet, is); removeStreamPools(fsPool, foPool, fo); }
if (get(fo).waitForInputStreamsClosed(fo, 2000) && get(fo).waitForOutputStreamsClosed(fo, 2000) ) { retVal = new NotifyOutputStream(fo, fireFileChanged); get(fo).oStream().add(retVal); get(fo.getFileSystem()).oStream().add(retVal);
super.refresh(added, removed, fire, expected, list); } else { StreamPool strPool = StreamPool.find(this); if ((strPool != null) && strPool.isOutputStreamOpen()) { return;
@Override public void close() throws IOException { if (!closed) { closed = true; ex = null; super.close(); closeInputStream(fo, this); synchronized (StreamPool.class) { if (!StreamPool.get(fo).isInputStreamOpen()) { StreamPool.class.notifyAll(); } } } }
/** fireFileChange defines if should be fired fileChanged event after close of stream*/ synchronized OutputStream getOutputStream(FileLock lock, boolean fireFileChanged) throws IOException { FileSystem fs = getAbstractFileSystem(); if (fs.isReadOnly()) { throw new FSException(NbBundle.getMessage(AbstractFileObject.class, "EXC_FSisRO", fs.getDisplayName())); } if (isReadOnly()) { throw new FSException(NbBundle.getMessage(AbstractFileObject.class, "EXC_FisRO", name, fs.getDisplayName())); } testLock(lock); return StreamPool.createOutputStream(this, fireFileChanged); }
private void waitForOutputStreamsClosed (int timeInMs) throws InterruptedException { synchronized (StreamPool.class) { if (isOutputStreamOpen ()) { StreamPool.class.wait(timeInMs); if (isOutputStreamOpen ()) { throw new InterruptedException(); } } } }
/** fireFileChange defines if should be fired fileChanged event after close of stream*/ private static void closeOutputStream(AbstractFolder fo, OutputStream os, boolean fireFileChanged) { StreamPool foPool = find(fo); StreamPool fsPool = find(fo.getFileSystem()); Set foSet = (foPool != null) ? foPool.oStreams : null; Set fsSet = (fsPool != null) ? fsPool.oStreams : null; removeStreams(fsSet, foSet, os); removeStreamPools(fsPool, foPool, fo); fo.outputStreamClosed(fireFileChanged); }
synchronized (StreamPool.class) { try { get (fo).waitForInputStreamsClosed(2000); get (fo).waitForOutputStreamsClosed(2000); get (fo).oStream ().add (retVal); get (fo.getFileSystem()).oStream ().add (retVal); } catch (InterruptedException e) { ExternalUtil.exception(e);
super.refresh (added, removed, fire, expected, list); } else { StreamPool strPool = StreamPool.find(this); if (strPool != null && strPool.isOutputStreamOpen()) return;
private void waitForInputStreamsClosed (int timeInMs) throws InterruptedException { synchronized (StreamPool.class) { if (isInputStreamOpen ()) { StreamPool.class.wait(timeInMs); if (isInputStreamOpen ()) { throw new InterruptedException(); } } } }
/** fireFileChange defines if should be fired fileChanged event after close of stream*/ synchronized OutputStream getOutputStream (FileLock lock, boolean fireFileChanged) throws java.io.IOException { FileSystem fs = getAbstractFileSystem (); if (fs.isReadOnly()) FSException.io("EXC_FSisRO", fs.getDisplayName ()); // NOI18N if (isReadOnly()) FSException.io("EXC_FisRO", name, fs.getDisplayName ()); // NOI18N testLock (lock); return StreamPool.createOutputStream(this, fireFileChanged); }
private void waitForOutputStreamsClosed (int timeInMs) throws InterruptedException { synchronized (StreamPool.class) { if (isOutputStreamOpen ()) { StreamPool.class.wait(timeInMs); if (isOutputStreamOpen ()) { throw new InterruptedException(); } } } }
private static void closeInputStream (AbstractFolder fo, InputStream is) { StreamPool foPool = find (fo); StreamPool fsPool = find (fo.getFileSystem ()); Set foSet = (foPool != null)? foPool.iStreams : null; Set fsSet = (fsPool != null)? fsPool.iStreams : null; removeStreams (fsSet, foSet, is); removeStreamPools (fsPool, foPool, fo); }