/** * create a new DirectoryEntry in the root directory * * @param name the name of the new DirectoryEntry * * @return the new DirectoryEntry * * @exception IOException on name duplication */ public DirectoryEntry createDirectory(final String name) throws IOException { return getRoot().createDirectory(name); }
@Override public int addOlePackage(byte[] oleData, String label, String fileName, String command) throws IOException { // check if we were created by POIFS otherwise create a new dummy POIFS for storing the package data if (initDirectory()) { preserveNodes = true; } // get free MBD-Node int storageId = 0; DirectoryEntry oleDir = null; do { String storageStr = "MBD"+ HexDump.toHex(++storageId); if (!getDirectory().hasEntry(storageStr)) { oleDir = getDirectory().createDirectory(storageStr); oleDir.setStorageClsid(ClassIDPredefined.OLE_V1_PACKAGE.getClassID()); } } while (oleDir == null); Ole10Native.createOleMarkerEntry(oleDir); Ole10Native oleNative = new Ole10Native(label, fileName, command, oleData); ByteArrayOutputStream bos = new ByteArrayOutputStream(); oleNative.writeOut(bos); oleDir.createDocument(Ole10Native.OLE10_NATIVE, new ByteArrayInputStream(bos.toByteArray())); return storageId; }
protected static void copyNodes(DirectoryNode src, DirectoryNode dest) throws IOException { for (Entry e : src) { if (e instanceof DirectoryNode) { DirectoryNode srcDir = (DirectoryNode)e; DirectoryNode destDir = (DirectoryNode)dest.createDirectory(srcDir.getName()); destDir.setStorageClsid(srcDir.getStorageClsid()); copyNodes(srcDir, destDir); } else { try (InputStream is = src.createDocumentInputStream(e)) { dest.createDocument(e.getName(), is); } } } }
/** * create a new DirectoryEntry in the root directory * * @param name the name of the new DirectoryEntry * * @return the new DirectoryEntry * * @exception IOException on name duplication */ public DirectoryEntry createDirectory(final String name) throws IOException { return getRoot().createDirectory(name); }
/** * create a new DirectoryEntry in the root directory * * @param name the name of the new DirectoryEntry * * @return the new DirectoryEntry * * @exception IOException on name duplication */ public DirectoryEntry createDirectory(final String name) throws IOException { return getRoot().createDirectory(name); }
/** * create a new DirectoryEntry in the root directory * * @param name the name of the new DirectoryEntry * * @return the new DirectoryEntry * * @exception IOException on name duplication */ public DirectoryEntry createDirectory(final String name) throws IOException { return getRoot().createDirectory(name); }
/** * create a new DirectoryEntry in the root directory * * @param name the name of the new DirectoryEntry * * @return the new DirectoryEntry * * @exception IOException on name duplication */ public DirectoryEntry createDirectory(final String name) throws IOException { return getRoot().createDirectory(name); }
/** * create a new DirectoryEntry in the root directory * * @param name the name of the new DirectoryEntry * * @return the new DirectoryEntry * * @exception IOException on name duplication */ public DirectoryEntry createDirectory(final String name) throws IOException { return getRoot().createDirectory(name); }
public void writeOut(DirectoryNode baseDir) throws IOException { String[] path = getPath(); // Ensure that all parent directories exist DirectoryNode dir = baseDir; for(int i=0; i<path.length-1; i++) { try { dir = (DirectoryNode)dir.getEntry(path[i]); } catch(FileNotFoundException e) { dir.createDirectory(path[i]); } } // Update the byte array with the latest data generateData(); // Write out ByteArrayInputStream bais = new ByteArrayInputStream(data); dir.createDocument(path[path.length-1], bais); }
public void writeOut(DirectoryNode baseDir) throws IOException { String[] path = getPath(); // Ensure that all parent directories exist DirectoryNode dir = baseDir; for(int i=0; i<path.length-1; i++) { try { dir = (DirectoryNode)dir.getEntry(path[i]); } catch(FileNotFoundException e) { dir.createDirectory(path[i]); } } // Update the byte array with the latest data generateData(); // Write out ByteArrayInputStream bais = new ByteArrayInputStream(data); dir.createDocument(path[path.length-1], bais); }
@Override public int addOlePackage(byte[] oleData, String label, String fileName, String command) throws IOException { // check if we were created by POIFS otherwise create a new dummy POIFS for storing the package data if (initDirectory()) { preserveNodes = true; } // get free MBD-Node int storageId = 0; DirectoryEntry oleDir = null; do { String storageStr = "MBD"+ HexDump.toHex(++storageId); if (!getDirectory().hasEntry(storageStr)) { oleDir = getDirectory().createDirectory(storageStr); oleDir.setStorageClsid(ClassIDPredefined.OLE_V1_PACKAGE.getClassID()); } } while (oleDir == null); Ole10Native.createOleMarkerEntry(oleDir); Ole10Native oleNative = new Ole10Native(label, fileName, command, oleData); ByteArrayOutputStream bos = new ByteArrayOutputStream(); oleNative.writeOut(bos); oleDir.createDocument(Ole10Native.OLE10_NATIVE, new ByteArrayInputStream(bos.toByteArray())); return storageId; }
protected static void copyNodes(DirectoryNode src, DirectoryNode dest) throws IOException { for (Entry e : src) { if (e instanceof DirectoryNode) { DirectoryNode srcDir = (DirectoryNode)e; DirectoryNode destDir = (DirectoryNode)dest.createDirectory(srcDir.getName()); destDir.setStorageClsid(srcDir.getStorageClsid()); copyNodes(srcDir, destDir); } else { try (InputStream is = src.createDocumentInputStream(e)) { dest.createDocument(e.getName(), is); } } } }
String storageStr = formatStorageId(++storageId); if (!root.hasEntry(storageStr)) { oleDir = root.createDirectory(storageStr); oleDir.setStorageClsid(PACKAGE.getClassID());
( DirectoryNode ) parent.createDirectory(name);
( DirectoryNode ) parent.createDirectory(name);