Return-Path: Delivered-To: apmail-poi-commits-archive@locus.apache.org Received: (qmail 20215 invoked from network); 29 Aug 2008 13:59:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 29 Aug 2008 13:59:47 -0000 Received: (qmail 45409 invoked by uid 500); 29 Aug 2008 13:59:46 -0000 Delivered-To: apmail-poi-commits-archive@poi.apache.org Received: (qmail 45366 invoked by uid 500); 29 Aug 2008 13:59:46 -0000 Mailing-List: contact commits-help@poi.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@poi.apache.org Delivered-To: mailing list commits@poi.apache.org Received: (qmail 45357 invoked by uid 99); 29 Aug 2008 13:59:46 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 29 Aug 2008 06:59:46 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 29 Aug 2008 13:58:56 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 0FBBE238896C; Fri, 29 Aug 2008 06:58:57 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r690259 - /poi/trunk/src/java/org/apache/poi/poifs/dev/POIFSDump.java Date: Fri, 29 Aug 2008 13:58:56 -0000 To: commits@poi.apache.org From: yegor@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080829135857.0FBBE238896C@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: yegor Date: Fri Aug 29 06:58:56 2008 New Revision: 690259 URL: http://svn.apache.org/viewvc?rev=690259&view=rev Log: utility to dump POIFS into filesystem Added: poi/trunk/src/java/org/apache/poi/poifs/dev/POIFSDump.java (with props) Added: poi/trunk/src/java/org/apache/poi/poifs/dev/POIFSDump.java URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/poifs/dev/POIFSDump.java?rev=690259&view=auto ============================================================================== --- poi/trunk/src/java/org/apache/poi/poifs/dev/POIFSDump.java (added) +++ poi/trunk/src/java/org/apache/poi/poifs/dev/POIFSDump.java Fri Aug 29 06:58:56 2008 @@ -0,0 +1,74 @@ +/* ==================================================================== + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +==================================================================== */ +package org.apache.poi.poifs.dev; + +import org.apache.poi.poifs.filesystem.*; + +import java.io.FileInputStream; +import java.io.File; +import java.io.IOException; +import java.io.FileOutputStream; +import java.util.Iterator; + +/** + * + * Dump internal structure of a OLE2 file into file system + * + * @author Yegor Kozlov + */ +public class POIFSDump { + + public static void main(String[] args) throws Exception { + for (int i = 0; i < args.length; i++) { + System.out.println("Dumping " + args[i]); + FileInputStream is = new FileInputStream(args[i]); + POIFSFileSystem fs = new POIFSFileSystem(is); + is.close(); + + DirectoryEntry root = fs.getRoot(); + File file = new File(root.getName()); + file.mkdir(); + + dump(root, file); + } + } + + + public static void dump(DirectoryEntry root, File parent) throws IOException { + for(Iterator it = root.getEntries(); it.hasNext();){ + Entry entry = (Entry)it.next(); + if(entry instanceof DocumentNode){ + DocumentNode node = (DocumentNode)entry; + DocumentInputStream is = new DocumentInputStream(node); + byte[] bytes = new byte[node.getSize()]; + is.read(bytes); + is.close(); + + FileOutputStream out = new FileOutputStream(new File(parent, node.getName().trim())); + out.write(bytes); + out.close(); + } else if (entry instanceof DirectoryEntry){ + DirectoryEntry dir = (DirectoryEntry)entry; + File file = new File(parent, entry.getName()); + file.mkdir(); + dump(dir, file); + } else { + System.err.println("Skipping unsupported POIFS entry: " + entry); + } + } + } +} Propchange: poi/trunk/src/java/org/apache/poi/poifs/dev/POIFSDump.java ------------------------------------------------------------------------------ svn:executable = * --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org For additional commands, e-mail: commits-help@poi.apache.org