Correct zero byte entry support in NPOIFS
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1678778 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0d95d3df70
commit
1945dfc00c
@ -143,8 +143,12 @@ public final class NPOIFSDocument implements POIFSViewable {
|
|||||||
os.write(buf, 0, readBytes);
|
os.write(buf, 0, readBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
os.close();
|
// If this is an empty document, write a single byte
|
||||||
|
// to force a block allocation for this document
|
||||||
|
if (length == 0) os.write(0);
|
||||||
|
|
||||||
|
// Tidy and return the length
|
||||||
|
os.close();
|
||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,6 @@ import org.apache.poi.poifs.property.Property;
|
|||||||
import org.apache.poi.poifs.property.RootProperty;
|
import org.apache.poi.poifs.property.RootProperty;
|
||||||
import org.apache.poi.poifs.storage.HeaderBlock;
|
import org.apache.poi.poifs.storage.HeaderBlock;
|
||||||
import org.apache.poi.util.IOUtils;
|
import org.apache.poi.util.IOUtils;
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1307,7 +1306,6 @@ public final class TestNPOIFSFileSystem {
|
|||||||
assertContentsMatches(main4106, normDoc);
|
assertContentsMatches(main4106, normDoc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore
|
|
||||||
@Test
|
@Test
|
||||||
public void writeZeroLengthEntries() throws Exception {
|
public void writeZeroLengthEntries() throws Exception {
|
||||||
NPOIFSFileSystem fs = new NPOIFSFileSystem();
|
NPOIFSFileSystem fs = new NPOIFSFileSystem();
|
||||||
@ -1350,6 +1348,7 @@ public final class TestNPOIFSFileSystem {
|
|||||||
|
|
||||||
// Save and re-check
|
// Save and re-check
|
||||||
fs = writeOutAndReadBack(fs);
|
fs = writeOutAndReadBack(fs);
|
||||||
|
testDir = fs.getRoot();
|
||||||
|
|
||||||
miniDoc = (DocumentEntry)testDir.getEntry("Mini2");
|
miniDoc = (DocumentEntry)testDir.getEntry("Mini2");
|
||||||
assertContentsMatches(mini2, miniDoc);
|
assertContentsMatches(mini2, miniDoc);
|
||||||
|
Loading…
Reference in New Issue
Block a user