@SuppressFBWarnings(value = "PATH_TRAVERSAL_IN", justification = "input files are specified by admin, not unchecked user input") @Override public File replicateFile(FileObject srcFile, FileSelector selector) throws FileSystemException { String baseName = srcFile.getName().getBaseName(); try { String safeBasename = UriParser.encode(baseName, TMP_RESERVED_CHARS).replace('%', '_'); File file = File.createTempFile("vfsr_", "_" + safeBasename, tempDir); file.deleteOnExit(); final FileObject destFile = context.toFileObject(file); destFile.copyFrom(srcFile, selector); return file; } catch (IOException e) { throw new FileSystemException(e); } }
/** * Return the FileSystemManager used to instantiate this filesystem. * * @return the FileSystemManager. */ @Override public FileSystemManager getFileSystemManager() { return getContext().getFileSystemManager(); }
/** * Creates a temporary local copy of a file and its descendants. * * @param file the start of the tree. * @param selector selection what to do with childs. * @return replicated root file. * @throws Exception any Exception is wrapped as FileSystemException. */ protected File doReplicateFile(final FileObject file, final FileSelector selector) throws Exception { return getContext().getReplicator().replicateFile(file, selector); }
@Override protected URLConnection openConnection(final URL url) throws IOException { final FileObject entry = context.resolveFile(url.toExternalForm(), fileSystemOptions); return new DefaultURLConnection(url, entry.getContent()); }
if (filesystem == null) { if (rootFile == null) { rootFile = getContext().getTemporaryFileStore().allocateFile("tempfs"); final FileName rootName = getContext().parseURI(scheme + ":" + FileName.ROOT_PATH);
/** * Locates a file object, by absolute URI. * * @param baseFile The base FileObject. * @param uri The uri of the file to locate. * @param fileSystemOptions The FileSystemOptions * @return The FileObject * @throws FileSystemException if an error occurs. */ @Override public synchronized FileObject findFile(final FileObject baseFile, final String uri, final FileSystemOptions fileSystemOptions) throws FileSystemException { try { final URL url = new URL(uri); final URL rootUrl = new URL(url, "/"); final String key = this.getClass().getName() + rootUrl.toString(); FileSystem fs = findFileSystem(key, fileSystemOptions); if (fs == null) { final String extForm = rootUrl.toExternalForm(); final FileName rootName = getContext().parseURI(extForm); // final FileName rootName = // new BasicFileName(rootUrl, FileName.ROOT_PATH); fs = new UrlFileSystem(rootName, fileSystemOptions); addFileSystem(key, fs); } return fs.resolveFile(url.getPath()); } catch (final MalformedURLException e) { throw new FileSystemException("vfs.provider.url/badly-formed-uri.error", uri, e); } }
@Override protected URLConnection openConnection(final URL url) throws IOException { final FileObject entry = context.resolveFile(url.toExternalForm(), fileSystemOptions); return new DefaultURLConnection(url, entry.getContent()); }
if (filesystem == null) { if (rootFile == null) { rootFile = getContext().getTemporaryFileStore().allocateFile("tempfs"); final FileName rootName = getContext().parseURI(scheme + ":" + FileName.ROOT_PATH);
/** * Locates a file object, by absolute URI. * * @param baseFile The base FileObject. * @param uri The uri of the file to locate. * @param fileSystemOptions The FileSystemOptions * @return The FileObject * @throws FileSystemException if an error occurs. */ @Override public synchronized FileObject findFile(final FileObject baseFile, final String uri, final FileSystemOptions fileSystemOptions) throws FileSystemException { try { final URL url = new URL(uri); final URL rootUrl = new URL(url, "/"); final String key = this.getClass().getName() + rootUrl.toString(); FileSystem fs = findFileSystem(key, fileSystemOptions); if (fs == null) { final String extForm = rootUrl.toExternalForm(); final FileName rootName = getContext().parseURI(extForm); // final FileName rootName = // new BasicFileName(rootUrl, FileName.ROOT_PATH); fs = new UrlFileSystem(rootName, fileSystemOptions); addFileSystem(key, fs); } return fs.resolveFile(url.getPath()); } catch (final MalformedURLException e) { throw new FileSystemException("vfs.provider.url/badly-formed-uri.error", uri, e); } }
/** * Return the FileSystemManager used to instantiate this filesystem. * * @return the FileSystemManager. */ @Override public FileSystemManager getFileSystemManager() { return getContext().getFileSystemManager(); }
@Override public File replicateFile(FileObject srcFile, FileSelector selector) throws FileSystemException { String baseName = srcFile.getName().getBaseName(); try { String safeBasename = UriParser.encode(baseName, TMP_RESERVED_CHARS).replace('%', '_'); File file = File.createTempFile("vfsr_", "_" + safeBasename, tempDir); file.deleteOnExit(); final FileObject destFile = context.toFileObject(file); destFile.copyFrom(srcFile, selector); return file; } catch (IOException e) { throw new FileSystemException(e); } }
@Override protected URLConnection openConnection(final URL url) throws IOException { final FileObject entry = context.resolveFile(url.toExternalForm(), fileSystemOptions); return new DefaultURLConnection(url, entry.getContent()); }
if (filesystem == null) { if (rootFile == null) { rootFile = getContext().getTemporaryFileStore().allocateFile("tempfs"); final FileName rootName = getContext().parseURI(scheme + ":" + FileName.ROOT_PATH);
@Override public FileName parseChildUri(final VfsComponentContext context, final FileName base, final String filename) throws FileSystemException { final StringBuilder name = new StringBuilder(); // Extract the scheme final String scheme = UriParser.extractScheme(filename, name); // Extract the Layered file URI final String rootUriName = extractRootName(name); FileName rootUri = null; if (rootUriName != null) { rootUri = context.parseURI(rootUriName); } // Decode and normalise the path UriParser.canonicalizePath(name, 0, name.length(), this); //UriParser.fixSeparators(name); final FileType fileType = UriParser.normalisePath(name); final String path = name.toString(); return new LayeredFileName(scheme, rootUri, path, fileType); } //[IntelliJ] / in WI-2449 Invalid descendent file name "ssh:" or directory a\b (on Linux) -----
/** * Creates a temporary local copy of a file and its descendants. * * @param file the start of the tree. * @param selector selection what to do with childs. * @return replicated root file. * @throws Exception any Exception is wrapped as FileSystemException. */ protected File doReplicateFile(final FileObject file, final FileSelector selector) throws Exception { return getContext().getReplicator().replicateFile(file, selector); }
/** * Return the FileSystemManager used to instantiate this filesystem. * @return the FileSystemManager. */ @Override public FileSystemManager getFileSystemManager() { return getContext().getFileSystemManager(); }
/** * Physically deletes the file from the filesystem. * * @param file The File to delete. */ protected void deleteFile(final File file) { try { final FileObject fileObject = getContext().toFileObject(file); fileObject.deleteAll(); } catch (final FileSystemException e) { final String message = Messages.getString("vfs.impl/delete-temp.warn", file.getName()); VfsLog.warn(getLogger(), log, message, e); } }
@Override protected URLConnection openConnection(final URL url) throws IOException { final FileObject entry = context.resolveFile(url.toExternalForm(), fileSystemOptions); return new DefaultURLConnection(url, entry.getContent()); }
/** * Locates a file object, by absolute URI. * * @param baseFile The base FileObject. * @param fileUri The uri of the file to locate. * @param fileSystemOptions The FileSystemOptions * @return The FileObject * @throws FileSystemException if an error occurs. */ @Override public synchronized FileObject findFile(final FileObject baseFile, final String fileUri, final FileSystemOptions fileSystemOptions) throws FileSystemException { try { final URI uri = URI.create(fileUri); final URI rootUri = uri.resolve("/"); final String key = this.getClass().getName() + rootUri.toString(); FileSystem fs = findFileSystem(key, fileSystemOptions); if (fs == null) { final String extForm = rootUri.toString(); final FileName rootName = getContext().parseURI(extForm); // final FileName rootName = // new BasicFileName(rootUrl, FileName.ROOT_PATH); fs = new UrlFileSystem(rootName, fileSystemOptions); addFileSystem(key, fs); } return fs.resolveFile(uri.getPath()); } catch (final Exception e) { throw new FileSystemException("vfs.provider.url/badly-formed-uri.error", fileUri, e); } }
/** * Creates a temporary local copy of a file and its descendants. */ protected File doReplicateFile(final FileObject file, final FileSelector selector) throws Exception { return getContext().getReplicator().replicateFile(file, selector); }