Skip to content

Commit

Permalink
/vsizip/: add read support for Deflate64 (fixes OSGeo#7013)
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed Jan 3, 2023
1 parent 30daf01 commit 90c9928
Show file tree
Hide file tree
Showing 17 changed files with 2,674 additions and 226 deletions.
Binary file added autotest/gcore/data/deflate64.zip
Binary file not shown.
33 changes: 33 additions & 0 deletions autotest/gcore/vsizip.py
Original file line number Diff line number Diff line change
Expand Up @@ -724,3 +724,36 @@ def test_vsizip_byte_zip64_local_header_zeroed():
"/vsizip/data/byte_zip64_local_header_zeroed.zip/byte.tif"
).size
assert size == 736


###############################################################################
def test_vsizip_deflate64():

filename = "/vsizip/data/deflate64.zip/100k_lines.txt"
size = gdal.VSIStatL(filename).size
assert size == 2188890

f = gdal.VSIFOpenL(filename, "rb")
assert f
try:
data = gdal.VSIFReadL(1, size, f)
assert len(data) == size
assert len(gdal.VSIFReadL(1, 1, f)) == 0
assert gdal.VSIFSeekL(f, 0, 0) == 0
data2 = gdal.VSIFReadL(1, size, f)
len_data2 = len(data2)
assert len_data2 == size
assert data2 == data
for (pos, nread) in [
(10000, 1000),
(1, 1),
(size - 1, 1),
(size // 2, size // 2 + 10),
]:
assert gdal.VSIFSeekL(f, pos, 0) == 0
data2 = gdal.VSIFReadL(1, nread, f)
len_data2 = len(data2)
assert len_data2 == min(nread, size - pos)
assert data2 == data[pos : pos + len_data2]
finally:
gdal.VSIFCloseL(f)
18 changes: 18 additions & 0 deletions frmts/zlib/contrib/infback9/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
add_library(
infback9 OBJECT
infback9.c
inftree9.c
minified_zutil.c)
set_property(TARGET infback9 PROPERTY POSITION_INDEPENDENT_CODE ${GDAL_OBJECT_LIBRARIES_POSITION_INDEPENDENT_CODE})
target_sources(${GDAL_LIB_TARGET_NAME} PRIVATE $<TARGET_OBJECTS:infback9>)
target_compile_options(infback9 PRIVATE ${GDAL_C_WARNING_FLAGS})
if (MSVC)
target_compile_options(infback9 PRIVATE ${GDAL_SOFTWARNFLAGS} /wd4131)
endif ()

include(GdalDriverHelper)
if (GDAL_USE_ZLIB_INTERNAL)
gdal_add_vendored_lib(infback9 libz)
else()
gdal_target_link_libraries(infback9 PRIVATE ZLIB::ZLIB)
endif ()
Loading

0 comments on commit 90c9928

Please sign in to comment.