ZIP archive cannot be unpacked, while other app holds it opened for read
Original Reporter info from Mantis: Python
-
Reporter name:
Original Reporter info from Mantis: Python
- Reporter name:
Description:
XLSX files (Microsoft Excel 2007) is a regular ZIP archive, that can be easily opened with paszlib. But when this file is opened for READING by Excel (or Lible/OpenCalc), unzOpen returns nil. That happened, because share violation occured: Excel/Calc holds file with fmShareDenyWrite but unzOpen expects fmShareExclusive access.
Steps to reproduce:
- Take any XLSX file.
- Use unzOpen. This opens file successfully (not nil will be returned).
- Close application and open XLSX file with Excel or OpenCalc.
- Try to open the same file with unzOpen. File wont't be opened, nil will be returned.
Additional information:
How to fix:
in file:
https://github.com/graemeg/freepascal/blob/master/packages/paszlib/src/ziputils.pas
in function fopen in lines, that appears like:
fopenread: fp := TFileStream.Create(strpas(filename), fmOpenRead);
add after fmOpenRead option: "or fmShareDenyWrite". This allows opening file in shareable read mode.
Mantis conversion info:
- Mantis ID: 35211
- OS: Windows
- OS Build: XP
- Build: latest
- Platform: Windows
- Version: 3.0.4
- Fixed in version: 3.3.1
- Fixed in revision: 41648 (#ea5ca774)
- Target version: 3.2.0