MultiFileSystem fs = getMultiFileSystem(); if (fs.isReadOnly()) { throw new FSException(NbBundle.getMessage(MultiFileObject.class, "EXC_FSisRO", fs.getDisplayName())); throw new FSException(NbBundle.getMessage(MultiFileObject.class, "EXC_FisRO", name, fs.getDisplayName())); throw new FSException(NbBundle.getMessage(MultiFileObject.class, "EXC_FoNotFolder", n, getPath(), fs.getDisplayName())); throw new FSException(NbBundle.getMessage(MultiFileObject.class, "EXC_DataAlreadyExist", n, fs.getDisplayName(), getPath())); FileSystem simple = fs.createWritableOn(fullName); getMultiFileSystem().unmaskFileOnAll(simple, fullName);
fs.beginAtomicAction(); throw new FSException(NbBundle.getMessage(MultiFileObject.class, "EXC_CannotDeleteRoot", fs.getDisplayName())); FileLock l = lck.findLock(leader); FileSystem simple = fs.createWritableOn(getPath()); if (fs.isReadOnly()) { throw new FSException(NbBundle.getMessage(MultiFileObject.class, "EXC_FSisRO", fs.getDisplayName())); getMultiFileSystem().maskFile(simple, getPath()); updateFoldersLock(getParent()); return ret; } finally { fs.finishAtomicAction();
public synchronized FileLock lock() throws IOException { if (lock != null) { FileLock f = (FileLock) lock.get(); if (f != null) { FileAlreadyLockedException alreadyLockedException = new FileAlreadyLockedException(getPath()); alreadyLockedException.initCause(lockedBy); throw alreadyLockedException; } } Set<? extends FileSystem> set = getMultiFileSystem().createLocksOn(getPath()); MfLock l = new MfLock(leader, delegates(), set); lock = new WeakReference<MfLock>(l); assert (lockedBy = new Throwable("Locked by:")) != null; //NOI18N return l; }
/** 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); } }
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; }
/** Finds the system to create writable version of the file on. * * @param name name of the file (full) * @return the first one * @exception IOException if the filesystem is readonly */ protected FileSystem createWritableOn(String name) throws IOException { if (isReadOnly()) { throw new FSException(NbBundle.getMessage(MultiFileSystem.class, "EXC_FSisRO", getDisplayName())); } return systems[WRITE_SYSTEM_INDEX]; }
throw new FSException(NbBundle.getMessage(MultiFileObject.class, "EXC_CannotRenameRoot", fs.getDisplayName())); getPath(), getMultiFileSystem().getDisplayName(), newFullName)); throw new FSException(NbBundle.getMessage(MultiFileObject.class, "EXC_FSisRO", getMultiFileSystem().getDisplayName())); FileSystem single = fs.createWritableOnForRename(oldFullName, newFullName); getMultiFileSystem().unmaskFileOnAll(single, newFullName); copyContent(this, leader); } else { if (getMultiFileSystem().delegates(oldFullName).hasMoreElements()) { getMultiFileSystem().maskFile(single, oldFullName); updateFoldersLock(getParent());
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(); } }
/** This method was added to achieve firing events that attributes * were changed after setDelegates. Events are not fired reliable but this solution was * choosed because of performance reasons. Attributes name is set to null - what means * that one of attributes was probably changed. */ void updateAllAfterSetDelegates(FileSystem[] oldFileSystems) { try { getMultiFileSystem().beginAtomicAction(); FileSystem[] fileSystems = getMultiFileSystem().getDelegates(); Enumeration<AbstractFolder> en = existingSubFiles(true); while (en.hasMoreElements()) { MultiFileObject mfo = (MultiFileObject) en.nextElement(); if (mfo.isFolder() && !mfo.isInitialized()) { continue; } if (mfo.hasListeners()) { String path = mfo.getPath(); FileObject oldLeader = findLeader(oldFileSystems, path); FileObject newLeader = findLeader(fileSystems, path); if ((oldLeader != null) && (newLeader != null) && !oldLeader.equals(newLeader)) { mfo.fileAttributeChanged0(new FileAttributeEvent(mfo, null, null, null)); } } mfo.freeAttribCache(); mfo.refresh(true); } } finally { getMultiFileSystem().finishAtomicAction(); } }
FileSystem[] arr = mfs.getDelegates(); FileSystem writable = mfs.writableLayer(name); FileObject fo = mfs.findResourceOn(arr[i], name); Number weight = fo.isRoot() && !mfs.canHaveRootAttributeOnReadOnlyFS(WEIGHT_ATTRIBUTE) ? 0 : weightOf(fo, writable); if (led == null || weight.doubleValue() > maxWeight.doubleValue()) { getMultiFileSystem().notifyMigration(this);
FileSystem fs = getMultiFileSystem().createWritableOn(path); FileObject fo = getMultiFileSystem().findResourceOn(fs, path); Object oldValue = null; String attrToSet = attrName;
/** 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); }
/** Root of the filesystem. */ public @Override FileObject getRoot() { return getMultiRoot(); }
/** Deletes a all mask files that mask the given file. All * higher levels then fs are checked and mask is deleted if necessary * @param fs filesystem where res is placed * @param res resource name of the file that should be unmasked * @exception IOException if it fails */ void unmaskFileOnAll(FileSystem fs, String res) throws IOException { FileSystem[] fss = this.getDelegates(); for (int i = 0; i < fss.length; i++) { if ((fss[i] == null) || fss[i].isReadOnly()) { continue; } unmaskFile(fss[i], res); /** unamsk on all higher levels, which mask files on fs-layer */ if (fss[i] == fs) { return; } } }
private final Enumeration<String> getAttributes(String path) { Set<String> s = new HashSet<String>(); FileSystem[] systems = getMultiFileSystem().getDelegates(); final boolean empty = path.length() == 0; FileObject fo = getMultiFileSystem().findResourceOn(systems[i], path);
/** Finds a root for given file system. It also counts with * redefined method findResourceOn. * * @param fs the filesystem to seach on * @return the root on the fs */ private FileObject root(FileSystem fs) { return getMultiFileSystem().findResourceOn(fs, ""); // NOI18N }
public @Override SystemAction[] getActions(final Set<FileObject> foSet) { List<SystemAction> al = new ArrayList<SystemAction>(101); // randomly choosen constant Set<SystemAction> uniq = new HashSet<SystemAction>(101); // not that randommly choosen final FileSystem[] del = this.getDelegates(); for (int i = 0; i < del.length; i++) { if (del[i] == null) { continue; } final SystemAction[] acts = del[i].getActions(foSet); for (int j = 0; j < acts.length; j++) { if (uniq.add(acts[j])) { al.add(acts[j]); } } } return al.toArray(new SystemAction[al.size()]); }
FileSystem[] arr = mfs.getDelegates (); FileObject fo = mfs.findResourceOn (arr[i], name); if (fo != null) { del.add (fo); fileChanged0 (new FileEvent (this)); getMultiFileSystem ().notifyMigration (this);
/** All objects that are beyond this one. * @return enumeration of FileObject */ private Enumeration<FileObject> delegates() { return getMultiFileSystem().delegates(getPath()); }
/** Tests the lock if it is valid, if not throws exception. * @param l lock to test * @return the mf lock for this file object */ private MfLock testLock(FileLock l) throws java.io.IOException { if (lock == null) { throw new FSException(NbBundle.getMessage(MultiFileObject.class, "EXC_InvalidLock", l, getPath(), getMultiFileSystem().getDisplayName(), lock)); } if (lock.get() != l) { throw new FSException(NbBundle.getMessage(MultiFileObject.class, "EXC_InvalidLock", l, getPath(), getMultiFileSystem().getDisplayName(), lock.get())); } return (MfLock) l; }