/** * Attaches this file object to its file resource. */ protected void doAttach() throws Exception { if (file == null) { // Remove the "file:///" // LocalFileName localFileName = (LocalFileName) getName(); String fileName = rootFile + getName().getPathDecoded(); // fileName = UriParser.decode(fileName); file = new File(fileName); } }
/** * Creates an input stream to read the file content from. */ InputStream getInputStream(long filePointer) throws IOException { final ChannelSftp channel = fileSystem.getChannel(); try { // hmmm - using the in memory method is soooo much faster ... // TODO - Don't read the entire file into memory. Use the // stream-based methods on ChannelSftp once they work properly final ByteArrayOutputStream outstr = new ByteArrayOutputStream(); try { channel.get(getName().getPathDecoded(), outstr, null, ChannelSftp.RESUME, filePointer); } catch (SftpException e) { throw new FileSystemException(e); } outstr.close(); return new ByteArrayInputStream(outstr.toByteArray()); } finally { fileSystem.putChannel(channel); } }
for (FileObject fo : containedFiles) { String pathDecoded = fo.getName().getPathDecoded(); names.add(pathDecoded);
/** * Attaches this file object to its file resource. */ protected void doAttach() throws Exception { if (file == null) { LayeredFileName layeredFileName = (LayeredFileName) getName(); String fileName = layeredFileName.getOuterName().getRootURI() + layeredFileName.getOuterName().getPathDecoded(); FileObject outer = getFileSystem().resolveFile(fileName); if (outer instanceof TruezipFileObject) { fileName = layeredFileName.getOuterName().getPathDecoded() + getName().getPathDecoded(); file = new File(fileName, ArchiveDetector.ALL); } else { fileObject = outer; DefaultFileSystemManager dfsMgr = (DefaultFileSystemManager) VFS.getManager(); file = new File(dfsMgr.getTemporaryFileStore().allocateFile(getName().getBaseName())); } } }