Summary: | [PATCH] add constructor NPOIFSFileSystem(FileChannel channel, boolean readOnly) | ||
---|---|---|---|
Product: | POI | Reporter: | Daniel Bonniot <bonniot> |
Component: | POIFS | Assignee: | POI Developers List <dev> |
Status: | RESOLVED FIXED | ||
Severity: | regression | CC: | bonniot |
Priority: | P2 | ||
Version: | 3.11-dev | ||
Target Milestone: | --- | ||
Hardware: | PC | ||
OS: | Linux | ||
Attachments: |
Proposed patch
Change read-only mode to true by default for FileChannels |
Description
Daniel Bonniot
2014-09-11 07:13:37 UTC
The File constructor is read only, as it mirrors the InputStream one. The InputStream one is read only to match that of POIFS, which is always read only when opened for reading as it doesn't support in-place updates. NPOIFS can do in-place updates if you want it to, which is why it needs to offer read+write options I've applied your patch in r1624226, along with a few related javadoc tweaks to hopefully make read or write clear, thanks! Nick, thanks for applying the patch so quickly and for the added comments. If I understand your argument for the File constructor being read-only to match InputStream, shouldn't that apply to the FileChannel as well? I.e. consistently use the read-only mode in all constructors. This change would have the added benefit that applications that pass a read-only FileChannel would not break when upgrading from 3.10 to 3.11. On the other hand, that could potentially break existing code, but only code using trunk or a 3.11 beta, which sounds like a lesser evil than breaking code using a released version. Attaching the proposed further patch. Created attachment 32002 [details]
Change read-only mode to true by default for FileChannels
|