From d99d2e559e2596ec1dcecbbf915870434d1f3a04 Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Thu, 24 Apr 2014 17:25:10 +0000 Subject: [PATCH] More unit tests for NPOIFS writing, and correct a bug in how bats get allocated in xbats. (Some issues still remain) git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1589800 13f79535-47bb-0310-9956-ffa450edef68 --- .../poifs/filesystem/NPOIFSFileSystem.java | 20 ++-- .../filesystem/TestNPOIFSFileSystem.java | 95 +++++++++++++------ 2 files changed, 81 insertions(+), 34 deletions(-) diff --git a/src/java/org/apache/poi/poifs/filesystem/NPOIFSFileSystem.java b/src/java/org/apache/poi/poifs/filesystem/NPOIFSFileSystem.java index efa195e233..53cb4b3655 100644 --- a/src/java/org/apache/poi/poifs/filesystem/NPOIFSFileSystem.java +++ b/src/java/org/apache/poi/poifs/filesystem/NPOIFSFileSystem.java @@ -530,7 +530,9 @@ public class NPOIFSFileSystem extends BlockStore if(xbat == null) { // Oh joy, we need a new XBAT too... xbat = createBAT(offset+1, false); + // Allocate our new BAT as the first block in the XBAT xbat.setValueAt(0, offset); + // And allocate the XBAT in the BAT bat.setValueAt(1, POIFSConstants.DIFAT_SECTOR_BLOCK); // Will go one place higher as XBAT added in @@ -546,12 +548,14 @@ public class NPOIFSFileSystem extends BlockStore } _xbat_blocks.add(xbat); _header.setXBATCount(_xbat_blocks.size()); - } - // Allocate us in the XBAT - for(int i=0; i