/** Constructor. Takes reference to file system this file belongs to. * * @param fs the file system * @param parent the parent object (folder) * @param name name of the object (e.g. <code>filename.ext</code>) */ public AbstractFolder(FileSystem fs, AbstractFolder parent, String name) { this.system = fs; this.parent = parent; this.name = name; validFlag = true; validRoot = (parent != null) ? (AbstractFolder) fs.getRoot() : null; }
private static void setDiskFileSystem(FileSystem fs) { Object o = fs.getRoot().getAttribute("SupportsRefreshForNoPublicAPI"); if (o instanceof Boolean && ((Boolean) o).booleanValue()) { synchronized (FileUtil.class) { diskFileSystem = fs; } } }
private static FileSystem[] computeDelegates() { List<FileSystem> arr = new ArrayList<FileSystem>(); arr.add(MEMORY); for (FileSystem f : ALL.allInstances()) { if (Boolean.TRUE.equals(f.getRoot().getAttribute("fallback"))) { // NOI18N continue; } arr.add(f); } arr.add(layers); for (FileSystem f : ALL.allInstances()) { if (Boolean.TRUE.equals(f.getRoot().getAttribute("fallback"))) { // NOI18N arr.add(f); } } return arr.toArray(new FileSystem[0]); }
/** * Refreshes all necessary filesystems. Not all instances of <code>FileObject</code> are refreshed * but just those that represent passed <code>files</code> and their children recursively. * @param files * @since 7.6 */ public static void refreshFor(File... files) { FileSystem fs = getDiskFileSystemFor(files); if (fs != null) { try { fs.getRoot().setAttribute("request_for_refreshing_files_be_aware_this_is_not_public_api", files); } catch (IOException ex) { Exceptions.printStackTrace(ex); } } }
boolean canHaveRootAttributeOnReadOnlyFS(String name) { Set<String> tmp = rootAttributes; if (tmp == null) { tmp = new HashSet<String>(); for (FileSystem fs : getDelegates()) { if (fs == null) { continue; } if (!fs.isReadOnly()) { continue; } Enumeration<String> en = fs.getRoot().getAttributes(); while (en.hasMoreElements()) { tmp.add(en.nextElement()); } rootAttributes = tmp; } } if (tmp == Collections.<String>emptySet()) { return true; } return tmp.contains(name); } }
/** Creates 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 maskFile(FileSystem fs, String res) throws IOException { FileObject where = findResourceOn(fs, fs.getRoot().getPath()); FileUtil.createData(where, res + MASK); }
fo = systems[i].getRoot();
FileSystem fs = en.nextElement(); String rootName = null; FileObject fsRoot = fs.getRoot(); File root = findFileInRepository(fsRoot);
try { InputStream is = fo.openInputStream(); org.openide.filesystems.FileObject tmp = FileUtil.createMemoryFileSystem().getRoot().createData("resolver.xml"); OutputStream os = tmp.getOutputStream(); for (;;) {
@Override public String toString() { if (!isValid()) { return super.toString() + " parent: " + parent + " validFlag: " + validFlag + " validRoot: " + validRoot + " isValidRoot: " + (getFileSystem().getRoot() == validRoot); } return super.toString(); }
FileSystem foFs = localFo.getFileSystem(); if (!foFs.isReadOnly() || getMultiFileSystem().canHaveRootAttributeOnReadOnlyFS(prefixattr)) { localFo = foFs.getRoot(); oPerf = getAttribute(localFo, prefixattr, ""); // NOI18N getMultiFileSystem().canHaveRootAttributeOnReadOnlyFS(prefixattr) ) { fo = systems[i].getRoot();
fo = fs.getRoot(); attrToSet = path.replace('/', '\\') + '\\' + attrName;
@Override @Nonnull public ResourceFile getRoot() { return createResourceFile(fileSystem.getRoot()); }
public final boolean isValid () { // valid if (parent == null) { return validFlag; } boolean isValidRoot = getFileSystem ().getRoot () == validRoot; return validFlag && isValidRoot; }
private void initCacheStore() { String userDir = System.getProperty("netbeans.user"); // NOI18N if (userDir != null) { cacheStore = new File(new File(new File (userDir, "var"), "cache"), DATA_DIRECTORY); // NOI18N } else { File cachedir = FileUtil.toFile(org.openide.filesystems.Repository.getDefault().getDefaultFileSystem().getRoot()); cacheStore = new File(cachedir, DATA_DIRECTORY); } cacheStore.mkdirs(); } }
private String getMimeType(String filename) { try { return FileUtil.createMemoryFileSystem().getRoot().createData(filename).getMIMEType(); } catch (IOException ex) { // ignored, should not happen LOGGER.log(Level.WARNING, null, ex); } return "content/unknown"; // NOI18N }
/** Creates 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 maskFile (FileSystem fs, String res) throws IOException { FileObject where = findResourceOn (fs,fs.getRoot().getPath ()); FileUtil.createData (where, res + MASK); }
protected DataObject createDataObject (final String name) throws IOException { final FileObject fileObject = fileSystem.getRoot().createData(name); assertNotNull(fileObject); final DataObject dataObject = DataObject.find(fileObject); assertNotNull(dataObject); return dataObject; } }
@Test public void testFindMetadataItemFromBadJPG() throws Exception { final DataObject dataObject = DataObject.find(FileUtil.createMemoryFileSystem().getRoot().createData("badfile")); final MetadataItemHolder<TIFF> holder = tiffProvider.findOrCreateItems(dataObject, EXTERNAL).iterator().next(); assertNotNull(holder); assertFalse(holder.isAvailable()); }