/** * {@inheritDoc} */ public InputStream openInputStream(final VirtualFile mountPoint, final VirtualFile target) throws IOException { return privileged ? doIoPrivileged(new PrivilegedExceptionAction<InputStream>() { public InputStream run() throws Exception { return new FileInputStream(getFile(mountPoint, target)); } }) : new FileInputStream(getFile(mountPoint, target)); }
public InputStream run() throws Exception { return new FileInputStream(getFile(mountPoint, target)); } }) : new FileInputStream(getFile(mountPoint, target));
/** * Create and mount a real file system, returning a single handle which will unmount and close the filesystem when * closed. * * @param realRoot the real filesystem root * @param mountPoint the point at which the filesystem should be mounted * @return a handle * @throws IOException if an error occurs */ public static Closeable mountReal(File realRoot, VirtualFile mountPoint) throws IOException { return doMount(new RealFileSystem(realRoot), mountPoint); }
/** * {@inheritDoc} */ public boolean delete(VirtualFile mountPoint, VirtualFile target) { final File file = getFile(mountPoint, target); return privileged ? doPrivileged(new PrivilegedAction<Boolean>() { public Boolean run() { return Boolean.valueOf(file.delete()); } }).booleanValue() : file.delete(); }
/** * Create and mount an expanded zip file in a temporary file system, returning a single handle which will unmount and * close the filesystem when closed. * * @param zipFile the zip file to mount * @param mountPoint the point at which the filesystem should be mounted * @param tempFileProvider the temporary file provider * @return a handle * @throws IOException if an error occurs */ public static Closeable mountZipExpanded(File zipFile, VirtualFile mountPoint, TempFileProvider tempFileProvider) throws IOException { boolean ok = false; final TempDir tempDir = tempFileProvider.createTempDir(zipFile.getName()); try { final File rootFile = tempDir.getRoot(); VFSUtils.unzip(zipFile, rootFile); final MountHandle handle = doMount(new RealFileSystem(rootFile), mountPoint, tempDir); ok = true; return handle; } finally { if (!ok) { VFSUtils.safeClose(tempDir); } } }
/** * {@inheritDoc} */ public long getSize(VirtualFile mountPoint, VirtualFile target) { final File file = getFile(mountPoint, target); return privileged ? doPrivileged(new PrivilegedAction<Long>() { public Long run() { return Long.valueOf(file.length()); } }).longValue() : file.length(); }
/** * Create and mount a temporary file system, returning a single handle which will unmount and close the filesystem * when closed. * * @param mountPoint the point at which the filesystem should be mounted * @param tempFileProvider the temporary file provider * @return a handle * @throws IOException if an error occurs */ public static Closeable mountTemp(VirtualFile mountPoint, TempFileProvider tempFileProvider) throws IOException { boolean ok = false; final TempDir tempDir = tempFileProvider.createTempDir("tmpfs"); try { final MountHandle handle = doMount(new RealFileSystem(tempDir.getRoot()), mountPoint, tempDir); ok = true; return handle; } finally { if (!ok) { VFSUtils.safeClose(tempDir); } } }
/** * {@inheritDoc} */ public boolean isFile(final VirtualFile mountPoint, final VirtualFile target) { final File file = getFile(mountPoint, target); return privileged ? doPrivileged(new PrivilegedAction<Boolean>() { public Boolean run() { return Boolean.valueOf(file.isFile()); } }).booleanValue() : file.isFile(); }
final MountHandle handle = doMount(new RealFileSystem(rootFile), mountPoint, tempDir); ok = true; return handle;
/** * {@inheritDoc} */ public long getLastModified(VirtualFile mountPoint, VirtualFile target) { final File file = getFile(mountPoint, target); return privileged ? doPrivileged(new PrivilegedAction<Long>() { public Long run() { return Long.valueOf(file.lastModified()); } }).longValue() : file.lastModified(); }
/** * {@inheritDoc} */ public boolean isDirectory(VirtualFile mountPoint, VirtualFile target) { final File file = getFile(mountPoint, target); return privileged ? doPrivileged(new PrivilegedAction<Boolean>() { public Boolean run() { return Boolean.valueOf(file.isDirectory()); } }).booleanValue() : file.isDirectory(); }
/** * {@inheritDoc} */ public List<String> getDirectoryEntries(VirtualFile mountPoint, VirtualFile target) { final File file = getFile(mountPoint, target); final String[] names = privileged ? doPrivileged(new PrivilegedAction<String[]>() { public String[] run() { return file.list(); } }) : file.list(); return names == null ? Collections.<String>emptyList() : Arrays.asList(names); }
/** * {@inheritDoc} */ public boolean exists(VirtualFile mountPoint, VirtualFile target) { final File file = getFile(mountPoint, target); return privileged ? doPrivileged(new PrivilegedAction<Boolean>() { public Boolean run() { return Boolean.valueOf(VFSUtils.exists(file)); } }).booleanValue() : VFSUtils.exists(file); }