/** Special case of createWritableOn (@see #createWritableOn). * * @param oldName original name of the file (full) * @param newName name new of the file (full) * @return the first one * @exception IOException if the filesystem is readonly * @since 1.34 */ protected FileSystem createWritableOnForRename(String oldName, String newName) throws IOException { return createWritableOn(newName); }
/** When a file is about to be locked this method is consulted to * choose which delegates should be locked. By default this method * returns only one filesystem; the same returned by createWritableOn. * <P> * If an delegate resides on a filesystem returned in the resulting * set, it will be locked. All others will remain unlocked. * * @param name the resource name to lock * @return set of filesystems * @exception IOException if the resource cannot be locked */ protected Set<? extends FileSystem> createLocksOn(String name) throws IOException { FileSystem writable = createWritableOn(name); return Collections.singleton(writable); }
FileSystem writableLayer(String path) { if (!insideWritableLayer.get() && /* #183936 */!isReadOnly()) { // #181460: avoid stack overflow when createWritableOn calls e.g. findResource insideWritableLayer.set(true); try { return createWritableOn(path); } catch (IOException x) { // ignore } finally { insideWritableLayer.set(false); } } return systems.length > WRITE_SYSTEM_INDEX ? systems[WRITE_SYSTEM_INDEX] : null; }
/** Marks a resource as hidden. It will not be listed in the list of files. * Uses createMaskOn method to determine on which filesystem to mark the file. * * @param res resource name of file to hide or show * @param hide true if we should hide the file/false otherwise * @exception IOException if it is not possible */ protected final void hideResource(String res, boolean hide) throws IOException { if (hide) { // mask file maskFile(createWritableOn(res), res); } else { unmaskFile(createWritableOn(res), res); } }
@Deprecated // have to override for compat public boolean isReadOnly() { MultiFileSystem fs = getMultiFileSystem(); if (fs.isReadOnly()) { return true; } if (leader.isReadOnly()) { // if we can make it writable then nothing try { FileSystem simple = fs.createWritableOn(getPath()); return simple == leader.getFileSystem(); } catch (IOException e) { return true; } } return false; }
public boolean canWrite() { MultiFileSystem fs = getMultiFileSystem(); if (fs.isReadOnly()) { return false; } if (!leader.canWrite()) { // if we can make it writable then nothing try { FileSystem simple = fs.createWritableOn(getPath()); return simple != leader.getFileSystem(); } catch (IOException e) { return false; } } return true; }
FileSystem simple = fs.createWritableOn(fullName);
FileSystem simple = fs.createWritableOn(fullName);
FileLock l = lck.findLock(leader); FileSystem simple = fs.createWritableOn(getPath());
/** Converts the file to be writable. * The file has to be locked! * * @return file object (new leader) that is writable * @exception IOException if the object cannot be writable */ private FileObject writable(boolean copyContents) throws IOException { MultiFileSystem fs = getMultiFileSystem(); FileSystem single = fs.createWritableOn(getPath()); if (single != leader.getFileSystem()) { // if writing to a file that is not on writable fs => // copy it if (leader.isFolder()) { leader = FileUtil.createFolder(root(single), getPath()); } else { FileObject folder = FileUtil.createFolder(root(single), getParent().getPath()); if (copyContents) { leader = leader.copy(folder, leader.getName(), leader.getExt()); } else { leader = folder.createData(leader.getNameExt()); } } MfLock l = ((lock == null) ? null : lock.get()); if (l != null) { // update the lock l.addLock(leader); } } return leader; }
void handleDelete(FileLock lock) throws IOException { if (parent == null) { throw new FSException(NbBundle.getMessage(MultiFileObject.class, "EXC_CannotDeleteRoot", getMultiFileSystem().getDisplayName())); } MultiFileSystem fs = getMultiFileSystem(); try { getFileSystem().beginAtomicAction(); synchronized (parent) { String fullName = getPath(); FileSystem single = fs.createWritableOn(fullName); if (needsMask(lock, true)) { getMultiFileSystem().maskFile(single, fullName); updateFoldersLock(getParent()); } String n = name; validFlag = false; /** [PENDING] expected rename of some refresh method */ //parent.internalRefresh (null, n, true, false, null); parent.refresh(null, n, true, false); if (hasAtLeastOneListeners()) { fileDeleted0(new FileEvent(this)); } } } finally { getFileSystem().finishAtomicAction(); } }
FileSystem fs = getMultiFileSystem().createWritableOn(path); FileObject fo = getMultiFileSystem().findResourceOn(fs, path); Object oldValue = null;
/** Special case of createWritableOn (@see #createWritableOn). * * @param oldName original name of the file (full) * @param newName name new of the file (full) * @return the first one * @exception IOException if the filesystem is readonly * @since 1.34 */ protected FileSystem createWritableOnForRename (String oldName, String newName) throws IOException { return createWritableOn (newName); }
/** Special case of createWritableOn (@see #createWritableOn). * * @param oldName original name of the file (full) * @param newName name new of the file (full) * @return the first one * @exception IOException if the filesystem is readonly * @since 1.34 */ protected FileSystem createWritableOnForRename (String oldName, String newName) throws IOException { return createWritableOn (newName); }
/** When a file is about to be locked this method is consulted to * choose which delegates should be locked. By default this method * returns only one filesystem; the same returned by createWritableOn. * <P> * If an delegate resides on a filesystem returned in the resulting * set, it will be locked. All others will remain unlocked. * * @param name the resource name to lock * @return set of filesystems * @exception IOException if the resource cannot be locked */ protected java.util.Set createLocksOn (String name) throws IOException { FileSystem writable = createWritableOn (name); return java.util.Collections.singleton(writable); }
/** When a file is about to be locked this method is consulted to * choose which delegates should be locked. By default this method * returns only one filesystem; the same returned by createWritableOn. * <P> * If an delegate resides on a filesystem returned in the resulting * set, it will be locked. All others will remain unlocked. * * @param name the resource name to lock * @return set of filesystems * @exception IOException if the resource cannot be locked */ protected java.util.Set createLocksOn (String name) throws IOException { FileSystem writable = createWritableOn (name); return java.util.Collections.singleton(writable); }
/** Marks a resource as hidden. It will not be listed in the list of files. * Uses createMaskOn method to determine on which filesystem to mark the file. * * @param res resource name of file to hide or show * @param hide true if we should hide the file/false otherwise * @exception IOException if it is not possible */ protected final void hideResource (String res, boolean hide) throws IOException { if (hide) { // mask file maskFile (createWritableOn (res), res); } else { unmaskFile (createWritableOn (res), res); } }
/** Marks a resource as hidden. It will not be listed in the list of files. * Uses createMaskOn method to determine on which filesystem to mark the file. * * @param res resource name of file to hide or show * @param hide true if we should hide the file/false otherwise * @exception IOException if it is not possible */ protected final void hideResource (String res, boolean hide) throws IOException { if (hide) { // mask file maskFile (createWritableOn (res), res); } else { unmaskFile (createWritableOn (res), res); } }
@Override protected FileSystem createWritableOn(String name) throws IOException { if( name.endsWith(LayerUtil.HIDDEN) ) { FileObject fo = findResource(name); if( null != fo ) { try { FileSystem fs = findSystem(fo); if( fs.isReadOnly() ) throw new IOException(); } catch( IllegalArgumentException e ) { //ignore } } } return super.createWritableOn(name); } }
public boolean isReadOnly () { MultiFileSystem fs = getMultiFileSystem (); if (fs.isReadOnly ()) { return true; } if (leader.isReadOnly ()) { // if we can make it writable then nothing try { FileSystem simple = fs.createWritableOn (getPath ()); return simple == leader.getFileSystem (); } catch (IOException e) { return true; } } return false; }