public DirectoryEntry createDirectory(String name) throws IOException { return directory.createDirectory(name); }
/** * Copies an Entry into a target POIFS directory, recursively */ @Internal public static void copyNodeRecursively( Entry entry, DirectoryEntry target ) throws IOException { if ( entry.isDirectoryEntry() ) { DirectoryEntry dirEntry = (DirectoryEntry)entry; DirectoryEntry newTarget = target.createDirectory( entry.getName() ); newTarget.setStorageClsid( dirEntry.getStorageClsid() ); Iterator<Entry> entries = dirEntry.getEntries(); while ( entries.hasNext() ) { copyNodeRecursively( entries.next(), newTarget ); } } else { DocumentEntry dentry = (DocumentEntry) entry; DocumentInputStream dstream = new DocumentInputStream( dentry ); target.createDocument( dentry.getName(), dstream ); dstream.close(); } }
public static DocumentEntry createEncryptionEntry(DirectoryEntry dir, String path, EncryptionRecord out) throws IOException { String parts[] = path.split("/"); for (int i=0; i<parts.length-1; i++) { dir = dir.hasEntry(parts[i]) ? (DirectoryEntry)dir.getEntry(parts[i]) : dir.createDirectory(parts[i]); } final byte buf[] = new byte[5000]; LittleEndianByteArrayOutputStream bos = new LittleEndianByteArrayOutputStream(buf, 0); out.write(bos); String fileName = parts[parts.length-1]; if (dir.hasEntry(fileName)) { dir.getEntry(fileName).delete(); } return dir.createDocument(fileName, bos.getWriteIndex(), new POIFSWriterListener(){ public void processPOIFSWriterEvent(POIFSWriterEvent event) { try { event.getStream().write(buf, 0, event.getLimit()); } catch (IOException e) { throw new EncryptedDocumentException(e); } } }); }
protected void copy(DirectoryEntry sourceDir, DirectoryEntry destDir) throws IOException { for (Entry entry : sourceDir) { if (entry instanceof DirectoryEntry) { // Need to recurse DirectoryEntry newDir = destDir.createDirectory(entry.getName()); copy((DirectoryEntry) entry, newDir); } else { // Copy entry try (InputStream contents = new DocumentInputStream((DocumentEntry) entry)) { destDir.createDocument(entry.getName(), contents); } } } } }
protected void copy(DirectoryEntry sourceDir, DirectoryEntry destDir) throws IOException { for (org.apache.poi.poifs.filesystem.Entry entry : sourceDir) { if (entry instanceof DirectoryEntry) { // Need to recurse DirectoryEntry newDir = destDir.createDirectory(entry.getName()); copy((DirectoryEntry) entry, newDir); } else { // Copy entry try (InputStream contents = new DocumentInputStream((DocumentEntry) entry)) { destDir.createDocument(entry.getName(), contents); } } } } }
public DirectoryEntry createDirectory(String name) throws IOException { return directory.createDirectory(name); }
public DirectoryEntry createDirectory(String name) throws IOException { return directory.createDirectory(name); }
public DirectoryEntry createDirectory(String name) throws IOException { return directory.createDirectory(name); }
private void saveEntries(final DirectoryEntry source, final DirectoryEntry destination) throws IOException { for (Entry entry : source) { // Recursively save sub-entries. if (entry instanceof DirectoryEntry) { saveEntries((DirectoryEntry) entry, destination.createDirectory(entry.getName())); continue; } // Copy the entry. try (final InputStream contents = new DocumentInputStream((DocumentEntry) entry)) { destination.createDocument(entry.getName(), contents); } catch (IOException e) { logger.error("Unable to save embedded document \"{}\" in document: \"{}\".", entry.getName(), parent, e); } } } }
private void saveEntries(final DirectoryEntry source, final DirectoryEntry destination) throws IOException { for (Entry entry : source) { // Recursively save sub-entries or copy the entry. if (entry instanceof DirectoryEntry) { saveEntries((DirectoryEntry) entry, destination.createDirectory(entry.getName())); } else { try (final InputStream contents = new DocumentInputStream((DocumentEntry) entry)) { destination.createDocument(entry.getName(), contents); } } } } }
DirectoryEntry newTarget = target.createDirectory(entry.getName()); newTarget.setStorageClsid(dirEntry.getStorageClsid());
de = de.createDirectory(path.getComponent (path.length() - 1));
de = de.createDirectory(path.getComponent (path.length() - 1));
/** * Copies an Entry into a target POIFS directory, recursively */ @Internal public static void copyNodeRecursively( Entry entry, DirectoryEntry target ) throws IOException { // logger.log( POILogger.ERROR, "copyNodeRecursively called with "+entry.getName()+ // ","+target.getName()); DirectoryEntry newTarget = null; if ( entry.isDirectoryEntry() ) { newTarget = target.createDirectory( entry.getName() ); Iterator<Entry> entries = ( (DirectoryEntry) entry ).getEntries(); while ( entries.hasNext() ) { copyNodeRecursively( entries.next(), newTarget ); } } else { DocumentEntry dentry = (DocumentEntry) entry; DocumentInputStream dstream = new DocumentInputStream( dentry ); target.createDocument( dentry.getName(), dstream ); dstream.close(); } }
/** * Copies an Entry into a target POIFS directory, recursively */ @Internal public static void copyNodeRecursively( Entry entry, DirectoryEntry target ) throws IOException { if ( entry.isDirectoryEntry() ) { DirectoryEntry dirEntry = (DirectoryEntry)entry; DirectoryEntry newTarget = target.createDirectory( entry.getName() ); newTarget.setStorageClsid( dirEntry.getStorageClsid() ); Iterator<Entry> entries = dirEntry.getEntries(); while ( entries.hasNext() ) { copyNodeRecursively( entries.next(), newTarget ); } } else { DocumentEntry dentry = (DocumentEntry) entry; DocumentInputStream dstream = new DocumentInputStream( dentry ); target.createDocument( dentry.getName(), dstream ); dstream.close(); } }
/** * Copies an Entry into a target POIFS directory, recursively */ @Internal public static void copyNodeRecursively( Entry entry, DirectoryEntry target ) throws IOException { // System.err.println("copyNodeRecursively called with "+entry.getName()+ // ","+target.getName()); DirectoryEntry newTarget = null; if ( entry.isDirectoryEntry() ) { newTarget = target.createDirectory( entry.getName() ); Iterator<Entry> entries = ( (DirectoryEntry) entry ).getEntries(); while ( entries.hasNext() ) { copyNodeRecursively( entries.next(), newTarget ); } } else { DocumentEntry dentry = (DocumentEntry) entry; DocumentInputStream dstream = new DocumentInputStream( dentry ); target.createDocument( dentry.getName(), dstream ); dstream.close(); } }
public static DocumentEntry createEncryptionEntry(DirectoryEntry dir, String path, EncryptionRecord out) throws IOException { String parts[] = path.split("/"); for (int i=0; i<parts.length-1; i++) { dir = dir.hasEntry(parts[i]) ? (DirectoryEntry)dir.getEntry(parts[i]) : dir.createDirectory(parts[i]); } final byte buf[] = new byte[5000]; LittleEndianByteArrayOutputStream bos = new LittleEndianByteArrayOutputStream(buf, 0); out.write(bos); String fileName = parts[parts.length-1]; if (dir.hasEntry(fileName)) { dir.getEntry(fileName).delete(); } return dir.createDocument(fileName, bos.getWriteIndex(), new POIFSWriterListener(){ public void processPOIFSWriterEvent(POIFSWriterEvent event) { try { event.getStream().write(buf, 0, event.getLimit()); } catch (IOException e) { throw new EncryptedDocumentException(e); } } }); }