public FileSystem getFileSystem() { return decoratedFileObject.getFileSystem(); }
public DelegateFileObject(final FileName name, final AbstractFileSystem fileSystem, final FileObject file) throws FileSystemException { super(name, fileSystem); this.file = file; if (file != null) { file.getFileSystem().addListener(file, this); } }
/** * * @param file */ public DefaultFileOperations(final FileObject file) { fileObject = file; fsmanager = file.getFileSystem().getFileSystemManager(); }
/** * Queries the object if a simple rename to the filename of <code>newfile</code> * is possible. * * @param newfile the new filename * @return true if rename is possible */ public boolean canRenameTo(FileObject newfile) { if (getFileSystem() == newfile.getFileSystem()) { return true; } return false; }
public ZipFileSystem(final FileName rootName, final FileObject parentLayer, final FileSystemOptions fileSystemOptions) throws FileSystemException { super(rootName, parentLayer, fileSystemOptions); // Make a local copy of the file file = parentLayer.getFileSystem().replicateFile(parentLayer, Selectors.SELECT_SELF); // Open the Zip file if (!file.exists()) { // Don't need to do anything zipFile = null; return; } // zipFile = createZipFile(this.file); }
protected TarFileSystem(final FileName rootName, final FileObject parentLayer, final FileSystemOptions fileSystemOptions) throws FileSystemException { super(rootName, parentLayer, fileSystemOptions); // Make a local copy of the file file = parentLayer.getFileSystem().replicateFile(parentLayer, Selectors.SELECT_SELF); // Open the Tar file if (!file.exists()) { // Don't need to do anything tarFile = null; return; } // tarFile = createTarFile(this.file); }
public void putFile(final FileObject file) { Map files = getOrCreateFilesystemCache(file.getFileSystem()); files.put(file.getName(), file); }
public void putFile(final FileObject file) { synchronized (this) { Map files = getOrCreateFilesystemCache(file.getFileSystem()); // System.err.println(">>> " + files.size() + " put:" + file.toString()); files.put(file.getName(), file); } }
public void touchFile(final FileObject file) { // this moves the file back on top getFile(file.getFileSystem(), file.getName()); } }
protected void logout() throws TinkException, IOException { VFS.getManager().closeFileSystem(remote.getFileSystem()); }
/** * Resolves a URI, relative to a base file. */ public FileObject resolveFile(final FileObject baseFile, final String uri) throws FileSystemException { return resolveFile(baseFile, uri, baseFile == null ? null : baseFile .getFileSystem().getFileSystemOptions()); }
public void putFile(final FileObject file) { if (log.isDebugEnabled()) { log.debug("putFile: " + file.getName()); } Map files = getOrCreateFilesystemCache(file.getFileSystem()); Reference ref = createReference(file, refqueue); FileSystemAndNameKey key = new FileSystemAndNameKey(file .getFileSystem(), file.getName()); synchronized (files) { files.put(file.getName(), ref); refReverseMap.put(ref, key); } }
/** * Creates a layered file system. */ public FileObject createFileSystem(final String scheme, final FileObject file) throws FileSystemException { final FileProvider provider = (FileProvider) providers.get(scheme); if (provider == null) { throw new FileSystemException("vfs.impl/unknown-provider.error", new Object[] { scheme, file }); } return provider.createFileSystem(scheme, file, file.getFileSystem() .getFileSystemOptions()); }
public FsFileCollector( FileObject fsRoot ) throws FileSystemException { this.fsRoot = fsRoot; FileSystemManager fileSystemManager = fsRoot.getFileSystem().getFileSystemManager(); FileObject root = fileSystemManager.createVirtualFileSystem( fsRoot ); root.createFolder(); this.root = root; }
/** * Attaches or detaches the target file. */ public void setFile(final FileObject file) throws Exception { final FileType oldType = doGetType(); if (file != null) { file.getFileSystem().addListener(file, this); } this.file = file; maybeTypeChanged(oldType); }
private FileSystem getFileSystem() { if (fileSystem == null) { try { assert fileSystemAccess != null; String uri = getRootUri(); FileObject root = fileSystemAccess.resolveFile(null, uri); log.debug("Root: {}", uri); FileObject file = fileSystemAccess.getManager().createVirtualFileSystem(root); fileSystem = file.getFileSystem(); log.debug("File system: {}", fileSystem); } catch (FileSystemException e) { throw new XStoreException(e); } } return fileSystem; }
/** * Handles an out-of-date file. */ protected void handleOutOfDateFile(final FileObject srcFile, final FileObject destFile) throws FileSystemException { log("Copying " + srcFile + " to " + destFile); destFile.copyFrom(srcFile, Selectors.SELECT_SELF); if (preserveLastModified && srcFile.getFileSystem().hasCapability(Capability.GET_LAST_MODIFIED) && destFile.getFileSystem().hasCapability(Capability.SET_LAST_MODIFIED_FILE)) { final long lastModTime = srcFile.getContent().getLastModifiedTime(); destFile.getContent().setLastModifiedTime(lastModTime); } }
/** * Extracts the archive file {@code archiveFile} to {@code targetFolder}; both shall previously * exist. */ public void extractTo(File archiveFile, File targetFolder) throws IOException { FileSystemManager manager = VFS.getManager(); String sourceURI = resolveArchiveURI(archiveFile); // String targetURI = resolveArchiveURI(targetFolder); FileObject source = manager.resolveFile(sourceURI); if (manager.canCreateFileSystem(source)) { source = manager.createFileSystem(source); } FileObject target = manager.createVirtualFileSystem(manager.resolveFile(targetFolder .getAbsolutePath())); FileSelector selector = new AllFileSelector() { @Override public boolean includeFile(FileSelectInfo fileInfo) { LOGGER.fine("Uncompressing " + fileInfo.getFile().getName().getFriendlyURI()); return true; } }; target.copyFrom(source, selector); source.close(); manager.closeFileSystem(source.getFileSystem()); }
/** * Handles a single source file. */ protected void handleOutOfDateFile(final FileObject srcFile, final FileObject destFile) throws FileSystemException { if (!tryRename || !srcFile.canRenameTo(destFile)) { super.handleOutOfDateFile(srcFile, destFile); log("Deleting " + srcFile); srcFile.delete(Selectors.SELECT_SELF); } else { log("Rename " + srcFile + " to " + destFile); srcFile.moveTo(destFile); if (!isPreserveLastModified() && destFile.getFileSystem().hasCapability(Capability.SET_LAST_MODIFIED_FILE)) { destFile.getContent().setLastModifiedTime(System.currentTimeMillis()); } } } }
/** * Creates a virtual file system, with the supplied file as its root. */ public FileObject createFileSystem(final FileObject rootFile) throws FileSystemException { final FileName rootName = getContext().getFileSystemManager().resolveName(rootFile.getName(), FileName.ROOT_PATH); // final FileName rootName = // new BasicFileName(rootFile.getName(), FileName.ROOT_PATH); final VirtualFileSystem fs = new VirtualFileSystem(rootName, rootFile.getFileSystem().getFileSystemOptions()); addComponent(fs); fs.addJunction(FileName.ROOT_PATH, rootFile); return fs.getRoot(); }