return fsManager.resolveName(base, fileName).getURI(); return fsManager.resolveName(base, name.getBaseName()).getURI();
@Override public URL getURL(final String basePath, final String file) throws MalformedURLException { if ((basePath != null && UriParser.extractScheme(basePath) == null) || (basePath == null && UriParser.extractScheme(file) == null)) { return super.getURL(basePath, file); } try { final FileSystemManager fsManager = VFS.getManager(); FileName path; if (basePath != null && UriParser.extractScheme(file) == null) { final FileName base = fsManager.resolveURI(basePath); path = fsManager.resolveName(base, file); } else { path = fsManager.resolveURI(file); } final URLStreamHandler handler = new VFSURLStreamHandler(path); return new URL(null, path.getURI(), handler); } catch (final FileSystemException fse) { throw new ConfigurationRuntimeException("Could not parse basePath: " + basePath + " and fileName: " + file, fse); } }
/** * Removes a junction from this file system. * * @param junctionPoint The junction to remove. * @throws FileSystemException if an error occurs. */ @Override public void removeJunction(final String junctionPoint) throws FileSystemException { final FileName junctionName = getFileSystemManager().resolveName(getRootName(), junctionPoint); junctions.remove(junctionName); // TODO - remove from parents of junction point // TODO - detach all cached children of the junction point from their real file }
/** * Removes a junction from this file system. * * @param junctionPoint The junction to remove. * @throws FileSystemException if an error occurs. */ @Override public void removeJunction(final String junctionPoint) throws FileSystemException { final FileName junctionName = getFileSystemManager().resolveName(getRootName(), junctionPoint); junctions.remove(junctionName); // TODO - remove from parents of junction point // TODO - detach all cached children of the junction point from their real file }
/** * Removes a junction from this file system. * * @param junctionPoint The junction to remove. * @throws FileSystemException if an error occurs. */ @Override public void removeJunction(final String junctionPoint) throws FileSystemException { final FileName junctionName = getFileSystemManager().resolveName(getRootName(), junctionPoint); junctions.remove(junctionName); // TODO - remove from parents of junction point // TODO - detach all cached children of the junction point from their real file }
private static void testNames(final FileSystemManager mgr, final FileName rootName) throws FileSystemException { for (int i = 0; i < 10; i++) { // warmup jvm mgr.resolveName(rootName, "/many/path/elements/with%25esc/any%25where/to/file.txt"); } final long start = System.currentTimeMillis(); for (int i = 0; i < NUOF_RESOLVES; i++) { mgr.resolveName(rootName, "/many/path/elements/with%25esc/any%25where/to/file.txt"); } final long end = System.currentTimeMillis(); System.err.println("time to resolve " + NUOF_RESOLVES + " names: " + (end - start) + "ms"); } }
/** * Finds a file in this file system. * * @param nameStr The name of the file to resolve. * @return The located FileObject or null if none could be located. * @throws FileSystemException if an error occurs. */ @Override public FileObject resolveFile(final String nameStr) throws FileSystemException { // Resolve the name, and create the file final FileName name = getFileSystemManager().resolveName(rootName, nameStr); return resolveFile(name); }
/** * Finds a file in this file system. * * @param nameStr The name of the file to resolve. * @return The located FileObject or null if none could be located. * @throws FileSystemException if an error occurs. */ @Override public FileObject resolveFile(final String nameStr) throws FileSystemException { // Resolve the name, and create the file final FileName name = getFileSystemManager().resolveName(rootName, nameStr); return resolveFile(name); }
/** * Finds a file, relative to this file. * * @param path The path of the file to locate. Can either be a relative path, which is resolved relative to this * file, or an absolute path, which is resolved relative to the file system that contains this file. * @return The FileObject. * @throws FileSystemException if an error occurs. */ @Override public FileObject resolveFile(final String path) throws FileSystemException { final FileName otherName = fs.getFileSystemManager().resolveName(fileName, path); return fs.resolveFile(otherName); }
/** * Returns a child by name. * * @param name The name of the child to locate. * @param scope the NameScope. * @return The FileObject for the file or null if the child does not exist. * @throws FileSystemException if an error occurs. */ @Override public FileObject resolveFile(final String name, final NameScope scope) throws FileSystemException { // return fs.resolveFile(this.name.resolveName(name, scope)); return fs.resolveFile(fs.getFileSystemManager().resolveName(this.fileName, name, scope)); }
/** * Finds a file, relative to this file. * * @param path The path of the file to locate. Can either be a relative path, which is resolved relative to this * file, or an absolute path, which is resolved relative to the file system that contains this file. * @return The FileObject. * @throws FileSystemException if an error occurs. */ @Override public FileObject resolveFile(final String path) throws FileSystemException { final FileName otherName = fs.getFileSystemManager().resolveName(fileName, path); return fs.resolveFile(otherName); }
/** * Returns a child by name. * * @param name The name of the child to locate. * @param scope the NameScope. * @return The FileObject for the file or null if the child does not exist. * @throws FileSystemException if an error occurs. */ @Override public FileObject resolveFile(final String name, final NameScope scope) throws FileSystemException { // return fs.resolveFile(this.name.resolveName(name, scope)); return fs.resolveFile(fs.getFileSystemManager().resolveName(this.fileName, name, scope)); }
/** * Finds a file, relative to this file. * * @param path The path of the file to locate. Can either be a relative path, which is resolved relative to this * file, or an absolute path, which is resolved relative to the file system that contains this file. * @return The FileObject. * @throws FileSystemException if an error occurs. */ @Override public FileObject resolveFile(final String path) throws FileSystemException { final FileName otherName = fileSystem.getFileSystemManager().resolveName(fileName, path); return fileSystem.resolveFile(otherName); }
/** * Returns a child by name. * * @param name The name of the child to locate. * @param scope the NameScope. * @return The FileObject for the file or null if the child does not exist. * @throws FileSystemException if an error occurs. */ @Override public FileObject resolveFile(final String name, final NameScope scope) throws FileSystemException { // return fs.resolveFile(this.name.resolveName(name, scope)); return fileSystem.resolveFile(fileSystem.getFileSystemManager().resolveName(this.fileName, name, scope)); }
/** * Finds a file in this file system. * * @param nameStr The name of the file to resolve. * @return The located FileObject or null if none could be located. * @throws FileSystemException if an error occurs. */ @Override public FileObject resolveFile(final String nameStr) throws FileSystemException { // Resolve the name, and create the file final FileName name = getFileSystemManager().resolveName(rootName, nameStr); return resolveFile(name); }
/** * Finds a file in this file system. * @param nameStr The name of the file to resolve. * @return The located FileObject or null if none could be located. * @throws FileSystemException if an error occurs. */ @Override public FileObject resolveFile(final String nameStr) throws FileSystemException { // Resolve the name, and create the file final FileName name = getFileSystemManager().resolveName(rootName, nameStr); return resolveFile(name); }
/** * If the base name is {@code null}, the file system manager should fail throwing a FileSystemException. * * @see VFS-189 */ @Test(expected = FileSystemException.class) public void testResolveFileNameNull() throws FileSystemException { VFS.getManager().resolveName((FileName) null, "../"); } }
/** * If the base name is {@code null}, the file system manager should fail throwing a FileSystemException. * * @see VFS-189 */ @Test(expected = FileSystemException.class) public void testResolveFileNameNull() throws FileSystemException { VFS.getManager().resolveName((FileName) null, "../"); } }
private FileObject getLinkDestination() throws FileSystemException { if (linkDestination == null) { final String path; synchronized (getFileSystem()) { path = this.fileInfo == null ? null : this.fileInfo.getLink(); } final FileName parent = getName().getParent(); final FileName relativeTo = parent == null ? getName() : parent; final FileName linkDestinationName = getFileSystem().getFileSystemManager().resolveName(relativeTo, path); linkDestination = getFileSystem().resolveFile(linkDestinationName); } return linkDestination; }
/** * Creates a virtual file system, with the supplied file as its root. * * @param rootFile The root of the file system. * @return A FileObject in the FileSystem. * @throws FileSystemException if an error occurs. */ public FileObject createFileSystem(final FileObject rootFile) throws FileSystemException { final AbstractFileName rootName = (AbstractFileName) getContext().getFileSystemManager() .resolveName(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(); }