diff --git a/Makefile.in b/Makefile.in
index 583620372a..d2b234ea11 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -530,6 +530,7 @@ ALL_BASE_HEADERS = \
wx/fswatcher.h \
wx/generic/fswatcher.h \
wx/secretstore.h \
+ wx/lzmastream.h \
$(BASE_PLATFORM_HDR) \
wx/fs_inet.h \
wx/protocol/file.h \
@@ -713,6 +714,7 @@ ALL_PORTS_BASE_HEADERS = \
wx/fswatcher.h \
wx/generic/fswatcher.h \
wx/secretstore.h \
+ wx/lzmastream.h \
wx/unix/app.h \
wx/unix/apptbase.h \
wx/unix/apptrait.h \
@@ -851,6 +853,7 @@ ALL_BASE_SOURCES = \
src/common/fswatchercmn.cpp \
src/generic/fswatcherg.cpp \
src/common/secretstore.cpp \
+ src/common/lzmastream.cpp \
src/common/fdiodispatcher.cpp \
src/common/selectdispatcher.cpp \
src/unix/appunix.cpp \
@@ -1034,6 +1037,7 @@ MONODLL_OBJECTS = \
monodll_fswatchercmn.o \
monodll_fswatcherg.o \
monodll_common_secretstore.o \
+ monodll_lzmastream.o \
$(__BASE_PLATFORM_SRC_OBJECTS) \
monodll_event.o \
monodll_fs_mem.o \
@@ -1176,6 +1180,7 @@ MONOLIB_OBJECTS = \
monolib_fswatchercmn.o \
monolib_fswatcherg.o \
monolib_common_secretstore.o \
+ monolib_lzmastream.o \
$(__BASE_PLATFORM_SRC_OBJECTS_1) \
monolib_event.o \
monolib_fs_mem.o \
@@ -1307,6 +1312,7 @@ BASEDLL_OBJECTS = \
basedll_fswatchercmn.o \
basedll_fswatcherg.o \
basedll_common_secretstore.o \
+ basedll_lzmastream.o \
$(__BASE_PLATFORM_SRC_OBJECTS_2) \
basedll_event.o \
basedll_fs_mem.o \
@@ -1421,6 +1427,7 @@ BASELIB_OBJECTS = \
baselib_fswatchercmn.o \
baselib_fswatcherg.o \
baselib_common_secretstore.o \
+ baselib_lzmastream.o \
$(__BASE_PLATFORM_SRC_OBJECTS_3) \
baselib_event.o \
baselib_fs_mem.o \
@@ -16270,6 +16277,9 @@ monodll_fswatcherg.o: $(srcdir)/src/generic/fswatcherg.cpp $(MONODLL_ODEP)
monodll_common_secretstore.o: $(srcdir)/src/common/secretstore.cpp $(MONODLL_ODEP)
$(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/common/secretstore.cpp
+monodll_lzmastream.o: $(srcdir)/src/common/lzmastream.cpp $(MONODLL_ODEP)
+ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/common/lzmastream.cpp
+
monodll_unix_mimetype.o: $(srcdir)/src/unix/mimetype.cpp $(MONODLL_ODEP)
$(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/unix/mimetype.cpp
@@ -21529,6 +21539,9 @@ monolib_fswatcherg.o: $(srcdir)/src/generic/fswatcherg.cpp $(MONOLIB_ODEP)
monolib_common_secretstore.o: $(srcdir)/src/common/secretstore.cpp $(MONOLIB_ODEP)
$(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/common/secretstore.cpp
+monolib_lzmastream.o: $(srcdir)/src/common/lzmastream.cpp $(MONOLIB_ODEP)
+ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/common/lzmastream.cpp
+
monolib_unix_mimetype.o: $(srcdir)/src/unix/mimetype.cpp $(MONOLIB_ODEP)
$(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/unix/mimetype.cpp
@@ -26788,6 +26801,9 @@ basedll_fswatcherg.o: $(srcdir)/src/generic/fswatcherg.cpp $(BASEDLL_ODEP)
basedll_common_secretstore.o: $(srcdir)/src/common/secretstore.cpp $(BASEDLL_ODEP)
$(CXXC) -c -o $@ $(BASEDLL_CXXFLAGS) $(srcdir)/src/common/secretstore.cpp
+basedll_lzmastream.o: $(srcdir)/src/common/lzmastream.cpp $(BASEDLL_ODEP)
+ $(CXXC) -c -o $@ $(BASEDLL_CXXFLAGS) $(srcdir)/src/common/lzmastream.cpp
+
basedll_unix_mimetype.o: $(srcdir)/src/unix/mimetype.cpp $(BASEDLL_ODEP)
$(CXXC) -c -o $@ $(BASEDLL_CXXFLAGS) $(srcdir)/src/unix/mimetype.cpp
@@ -27265,6 +27281,9 @@ baselib_fswatcherg.o: $(srcdir)/src/generic/fswatcherg.cpp $(BASELIB_ODEP)
baselib_common_secretstore.o: $(srcdir)/src/common/secretstore.cpp $(BASELIB_ODEP)
$(CXXC) -c -o $@ $(BASELIB_CXXFLAGS) $(srcdir)/src/common/secretstore.cpp
+baselib_lzmastream.o: $(srcdir)/src/common/lzmastream.cpp $(BASELIB_ODEP)
+ $(CXXC) -c -o $@ $(BASELIB_CXXFLAGS) $(srcdir)/src/common/lzmastream.cpp
+
baselib_unix_mimetype.o: $(srcdir)/src/unix/mimetype.cpp $(BASELIB_ODEP)
$(CXXC) -c -o $@ $(BASELIB_CXXFLAGS) $(srcdir)/src/unix/mimetype.cpp
diff --git a/build/bakefiles/files.bkl b/build/bakefiles/files.bkl
index 0f38e0952f..d529b6d731 100644
--- a/build/bakefiles/files.bkl
+++ b/build/bakefiles/files.bkl
@@ -546,6 +546,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
src/common/fswatchercmn.cpp
src/generic/fswatcherg.cpp
src/common/secretstore.cpp
+ src/common/lzmastream.cpp
src/common/event.cpp
@@ -719,6 +720,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
wx/fswatcher.h
wx/generic/fswatcher.h
wx/secretstore.h
+ wx/lzmastream.h
diff --git a/build/cmake/files.cmake b/build/cmake/files.cmake
index d6d9c6becb..0acb0dc7df 100644
--- a/build/cmake/files.cmake
+++ b/build/cmake/files.cmake
@@ -458,6 +458,7 @@ set(BASE_CMN_SRC
src/common/zstream.cpp
src/common/fswatchercmn.cpp
src/generic/fswatcherg.cpp
+ src/common/lzmastream.cpp
)
set(BASE_AND_GUI_CMN_SRC
@@ -633,6 +634,7 @@ set(BASE_CMN_HDR
wx/meta/removeref.h
wx/fswatcher.h
wx/generic/fswatcher.h
+ wx/lzmastream.h
)
set(NET_UNIX_SRC
diff --git a/build/cmake/options.cmake b/build/cmake/options.cmake
index da0841511c..cb694379f3 100644
--- a/build/cmake/options.cmake
+++ b/build/cmake/options.cmake
@@ -67,6 +67,12 @@ wx_add_thirdparty_library(wxUSE_LIBJPEG JPEG "use libjpeg (JPEG file format)")
wx_add_thirdparty_library(wxUSE_LIBPNG PNG "use libpng (PNG image format)")
wx_add_thirdparty_library(wxUSE_LIBTIFF TIFF "use libtiff (TIFF file format)")
+wx_option(wxUSE_LIBLZMA "use LZMA compression" OFF)
+if(wxUSE_LIBLZMA)
+ find_package(LibLZMA REQUIRED)
+endif()
+set(wxTHIRD_PARTY_LIBRARIES ${wxTHIRD_PARTY_LIBRARIES} wxUSE_LIBLZMA "use liblzma for LZMA compression")
+
wx_option(wxUSE_OPENGL "use OpenGL (or Mesa)")
if(NOT WIN32)
diff --git a/build/cmake/setup.h.in b/build/cmake/setup.h.in
index 4f244d7da4..ae4ade5175 100644
--- a/build/cmake/setup.h.in
+++ b/build/cmake/setup.h.in
@@ -275,6 +275,8 @@
#cmakedefine01 wxUSE_ZLIB
+#cmakedefine01 wxUSE_LIBLZMA
+
#cmakedefine01 wxUSE_APPLE_IEEE
#cmakedefine01 wxUSE_JOYSTICK
diff --git a/build/files b/build/files
index e81c72ebdc..166aab50a1 100644
--- a/build/files
+++ b/build/files
@@ -433,6 +433,7 @@ BASE_CMN_SRC =
src/common/list.cpp
src/common/log.cpp
src/common/longlong.cpp
+ src/common/lzmastream.cpp
src/common/memory.cpp
src/common/mimecmn.cpp
src/common/module.cpp
@@ -559,6 +560,7 @@ BASE_CMN_HDR =
wx/listimpl.cpp
wx/log.h
wx/longlong.h
+ wx/lzmastream.h
wx/math.h
wx/memconf.h
wx/memory.h
diff --git a/build/msw/makefile.bcc b/build/msw/makefile.bcc
index 0c23f0a938..334895a139 100644
--- a/build/msw/makefile.bcc
+++ b/build/msw/makefile.bcc
@@ -455,6 +455,7 @@ MONODLL_OBJECTS = \
$(OBJS)\monodll_fswatchercmn.obj \
$(OBJS)\monodll_fswatcherg.obj \
$(OBJS)\monodll_common_secretstore.obj \
+ $(OBJS)\monodll_lzmastream.obj \
$(OBJS)\monodll_basemsw.obj \
$(OBJS)\monodll_crashrpt.obj \
$(OBJS)\monodll_debughlp.obj \
@@ -607,6 +608,7 @@ MONOLIB_OBJECTS = \
$(OBJS)\monolib_fswatchercmn.obj \
$(OBJS)\monolib_fswatcherg.obj \
$(OBJS)\monolib_common_secretstore.obj \
+ $(OBJS)\monolib_lzmastream.obj \
$(OBJS)\monolib_basemsw.obj \
$(OBJS)\monolib_crashrpt.obj \
$(OBJS)\monolib_debughlp.obj \
@@ -755,6 +757,7 @@ BASEDLL_OBJECTS = \
$(OBJS)\basedll_fswatchercmn.obj \
$(OBJS)\basedll_fswatcherg.obj \
$(OBJS)\basedll_common_secretstore.obj \
+ $(OBJS)\basedll_lzmastream.obj \
$(OBJS)\basedll_basemsw.obj \
$(OBJS)\basedll_crashrpt.obj \
$(OBJS)\basedll_debughlp.obj \
@@ -888,6 +891,7 @@ BASELIB_OBJECTS = \
$(OBJS)\baselib_fswatchercmn.obj \
$(OBJS)\baselib_fswatcherg.obj \
$(OBJS)\baselib_common_secretstore.obj \
+ $(OBJS)\baselib_lzmastream.obj \
$(OBJS)\baselib_basemsw.obj \
$(OBJS)\baselib_crashrpt.obj \
$(OBJS)\baselib_debughlp.obj \
@@ -6690,6 +6694,9 @@ $(OBJS)\monodll_fswatcherg.obj: ..\..\src\generic\fswatcherg.cpp
$(OBJS)\monodll_common_secretstore.obj: ..\..\src\common\secretstore.cpp
$(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) ..\..\src\common\secretstore.cpp
+$(OBJS)\monodll_lzmastream.obj: ..\..\src\common\lzmastream.cpp
+ $(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) ..\..\src\common\lzmastream.cpp
+
$(OBJS)\monodll_basemsw.obj: ..\..\src\msw\basemsw.cpp
$(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) ..\..\src\msw\basemsw.cpp
@@ -9236,6 +9243,9 @@ $(OBJS)\monolib_fswatcherg.obj: ..\..\src\generic\fswatcherg.cpp
$(OBJS)\monolib_common_secretstore.obj: ..\..\src\common\secretstore.cpp
$(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) ..\..\src\common\secretstore.cpp
+$(OBJS)\monolib_lzmastream.obj: ..\..\src\common\lzmastream.cpp
+ $(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) ..\..\src\common\lzmastream.cpp
+
$(OBJS)\monolib_basemsw.obj: ..\..\src\msw\basemsw.cpp
$(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) ..\..\src\msw\basemsw.cpp
@@ -11782,6 +11792,9 @@ $(OBJS)\basedll_fswatcherg.obj: ..\..\src\generic\fswatcherg.cpp
$(OBJS)\basedll_common_secretstore.obj: ..\..\src\common\secretstore.cpp
$(CXX) -q -c -P -o$@ $(BASEDLL_CXXFLAGS) ..\..\src\common\secretstore.cpp
+$(OBJS)\basedll_lzmastream.obj: ..\..\src\common\lzmastream.cpp
+ $(CXX) -q -c -P -o$@ $(BASEDLL_CXXFLAGS) ..\..\src\common\lzmastream.cpp
+
$(OBJS)\basedll_basemsw.obj: ..\..\src\msw\basemsw.cpp
$(CXX) -q -c -P -o$@ $(BASEDLL_CXXFLAGS) ..\..\src\msw\basemsw.cpp
@@ -12127,6 +12140,9 @@ $(OBJS)\baselib_fswatcherg.obj: ..\..\src\generic\fswatcherg.cpp
$(OBJS)\baselib_common_secretstore.obj: ..\..\src\common\secretstore.cpp
$(CXX) -q -c -P -o$@ $(BASELIB_CXXFLAGS) ..\..\src\common\secretstore.cpp
+$(OBJS)\baselib_lzmastream.obj: ..\..\src\common\lzmastream.cpp
+ $(CXX) -q -c -P -o$@ $(BASELIB_CXXFLAGS) ..\..\src\common\lzmastream.cpp
+
$(OBJS)\baselib_basemsw.obj: ..\..\src\msw\basemsw.cpp
$(CXX) -q -c -P -o$@ $(BASELIB_CXXFLAGS) ..\..\src\msw\basemsw.cpp
diff --git a/build/msw/makefile.gcc b/build/msw/makefile.gcc
index 4272f38c1a..7a686f28c3 100644
--- a/build/msw/makefile.gcc
+++ b/build/msw/makefile.gcc
@@ -443,6 +443,7 @@ MONODLL_OBJECTS = \
$(OBJS)\monodll_fswatchercmn.o \
$(OBJS)\monodll_fswatcherg.o \
$(OBJS)\monodll_common_secretstore.o \
+ $(OBJS)\monodll_lzmastream.o \
$(OBJS)\monodll_basemsw.o \
$(OBJS)\monodll_crashrpt.o \
$(OBJS)\monodll_debughlp.o \
@@ -596,6 +597,7 @@ MONOLIB_OBJECTS = \
$(OBJS)\monolib_fswatchercmn.o \
$(OBJS)\monolib_fswatcherg.o \
$(OBJS)\monolib_common_secretstore.o \
+ $(OBJS)\monolib_lzmastream.o \
$(OBJS)\monolib_basemsw.o \
$(OBJS)\monolib_crashrpt.o \
$(OBJS)\monolib_debughlp.o \
@@ -745,6 +747,7 @@ BASEDLL_OBJECTS = \
$(OBJS)\basedll_fswatchercmn.o \
$(OBJS)\basedll_fswatcherg.o \
$(OBJS)\basedll_common_secretstore.o \
+ $(OBJS)\basedll_lzmastream.o \
$(OBJS)\basedll_basemsw.o \
$(OBJS)\basedll_crashrpt.o \
$(OBJS)\basedll_debughlp.o \
@@ -878,6 +881,7 @@ BASELIB_OBJECTS = \
$(OBJS)\baselib_fswatchercmn.o \
$(OBJS)\baselib_fswatcherg.o \
$(OBJS)\baselib_common_secretstore.o \
+ $(OBJS)\baselib_lzmastream.o \
$(OBJS)\baselib_basemsw.o \
$(OBJS)\baselib_crashrpt.o \
$(OBJS)\baselib_debughlp.o \
@@ -6872,6 +6876,9 @@ $(OBJS)\monodll_fswatcherg.o: ../../src/generic/fswatcherg.cpp
$(OBJS)\monodll_common_secretstore.o: ../../src/common/secretstore.cpp
$(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $<
+$(OBJS)\monodll_lzmastream.o: ../../src/common/lzmastream.cpp
+ $(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $<
+
$(OBJS)\monodll_basemsw.o: ../../src/msw/basemsw.cpp
$(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $<
@@ -9420,6 +9427,9 @@ $(OBJS)\monolib_fswatcherg.o: ../../src/generic/fswatcherg.cpp
$(OBJS)\monolib_common_secretstore.o: ../../src/common/secretstore.cpp
$(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $<
+$(OBJS)\monolib_lzmastream.o: ../../src/common/lzmastream.cpp
+ $(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $<
+
$(OBJS)\monolib_basemsw.o: ../../src/msw/basemsw.cpp
$(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $<
@@ -11968,6 +11978,9 @@ $(OBJS)\basedll_fswatcherg.o: ../../src/generic/fswatcherg.cpp
$(OBJS)\basedll_common_secretstore.o: ../../src/common/secretstore.cpp
$(CXX) -c -o $@ $(BASEDLL_CXXFLAGS) $(CPPDEPS) $<
+$(OBJS)\basedll_lzmastream.o: ../../src/common/lzmastream.cpp
+ $(CXX) -c -o $@ $(BASEDLL_CXXFLAGS) $(CPPDEPS) $<
+
$(OBJS)\basedll_basemsw.o: ../../src/msw/basemsw.cpp
$(CXX) -c -o $@ $(BASEDLL_CXXFLAGS) $(CPPDEPS) $<
@@ -12313,6 +12326,9 @@ $(OBJS)\baselib_fswatcherg.o: ../../src/generic/fswatcherg.cpp
$(OBJS)\baselib_common_secretstore.o: ../../src/common/secretstore.cpp
$(CXX) -c -o $@ $(BASELIB_CXXFLAGS) $(CPPDEPS) $<
+$(OBJS)\baselib_lzmastream.o: ../../src/common/lzmastream.cpp
+ $(CXX) -c -o $@ $(BASELIB_CXXFLAGS) $(CPPDEPS) $<
+
$(OBJS)\baselib_basemsw.o: ../../src/msw/basemsw.cpp
$(CXX) -c -o $@ $(BASELIB_CXXFLAGS) $(CPPDEPS) $<
diff --git a/build/msw/makefile.vc b/build/msw/makefile.vc
index b2965f5f63..1015011203 100644
--- a/build/msw/makefile.vc
+++ b/build/msw/makefile.vc
@@ -475,6 +475,7 @@ MONODLL_OBJECTS = \
$(OBJS)\monodll_fswatchercmn.obj \
$(OBJS)\monodll_fswatcherg.obj \
$(OBJS)\monodll_common_secretstore.obj \
+ $(OBJS)\monodll_lzmastream.obj \
$(OBJS)\monodll_basemsw.obj \
$(OBJS)\monodll_crashrpt.obj \
$(OBJS)\monodll_debughlp.obj \
@@ -637,6 +638,7 @@ MONOLIB_OBJECTS = \
$(OBJS)\monolib_fswatchercmn.obj \
$(OBJS)\monolib_fswatcherg.obj \
$(OBJS)\monolib_common_secretstore.obj \
+ $(OBJS)\monolib_lzmastream.obj \
$(OBJS)\monolib_basemsw.obj \
$(OBJS)\monolib_crashrpt.obj \
$(OBJS)\monolib_debughlp.obj \
@@ -793,6 +795,7 @@ BASEDLL_OBJECTS = \
$(OBJS)\basedll_fswatchercmn.obj \
$(OBJS)\basedll_fswatcherg.obj \
$(OBJS)\basedll_common_secretstore.obj \
+ $(OBJS)\basedll_lzmastream.obj \
$(OBJS)\basedll_basemsw.obj \
$(OBJS)\basedll_crashrpt.obj \
$(OBJS)\basedll_debughlp.obj \
@@ -936,6 +939,7 @@ BASELIB_OBJECTS = \
$(OBJS)\baselib_fswatchercmn.obj \
$(OBJS)\baselib_fswatcherg.obj \
$(OBJS)\baselib_common_secretstore.obj \
+ $(OBJS)\baselib_lzmastream.obj \
$(OBJS)\baselib_basemsw.obj \
$(OBJS)\baselib_crashrpt.obj \
$(OBJS)\baselib_debughlp.obj \
@@ -7387,6 +7391,9 @@ $(OBJS)\monodll_fswatcherg.obj: ..\..\src\generic\fswatcherg.cpp
$(OBJS)\monodll_common_secretstore.obj: ..\..\src\common\secretstore.cpp
$(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) ..\..\src\common\secretstore.cpp
+$(OBJS)\monodll_lzmastream.obj: ..\..\src\common\lzmastream.cpp
+ $(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) ..\..\src\common\lzmastream.cpp
+
$(OBJS)\monodll_basemsw.obj: ..\..\src\msw\basemsw.cpp
$(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) ..\..\src\msw\basemsw.cpp
@@ -9933,6 +9940,9 @@ $(OBJS)\monolib_fswatcherg.obj: ..\..\src\generic\fswatcherg.cpp
$(OBJS)\monolib_common_secretstore.obj: ..\..\src\common\secretstore.cpp
$(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) ..\..\src\common\secretstore.cpp
+$(OBJS)\monolib_lzmastream.obj: ..\..\src\common\lzmastream.cpp
+ $(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) ..\..\src\common\lzmastream.cpp
+
$(OBJS)\monolib_basemsw.obj: ..\..\src\msw\basemsw.cpp
$(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) ..\..\src\msw\basemsw.cpp
@@ -12479,6 +12489,9 @@ $(OBJS)\basedll_fswatcherg.obj: ..\..\src\generic\fswatcherg.cpp
$(OBJS)\basedll_common_secretstore.obj: ..\..\src\common\secretstore.cpp
$(CXX) /c /nologo /TP /Fo$@ $(BASEDLL_CXXFLAGS) ..\..\src\common\secretstore.cpp
+$(OBJS)\basedll_lzmastream.obj: ..\..\src\common\lzmastream.cpp
+ $(CXX) /c /nologo /TP /Fo$@ $(BASEDLL_CXXFLAGS) ..\..\src\common\lzmastream.cpp
+
$(OBJS)\basedll_basemsw.obj: ..\..\src\msw\basemsw.cpp
$(CXX) /c /nologo /TP /Fo$@ $(BASEDLL_CXXFLAGS) ..\..\src\msw\basemsw.cpp
@@ -12824,6 +12837,9 @@ $(OBJS)\baselib_fswatcherg.obj: ..\..\src\generic\fswatcherg.cpp
$(OBJS)\baselib_common_secretstore.obj: ..\..\src\common\secretstore.cpp
$(CXX) /c /nologo /TP /Fo$@ $(BASELIB_CXXFLAGS) ..\..\src\common\secretstore.cpp
+$(OBJS)\baselib_lzmastream.obj: ..\..\src\common\lzmastream.cpp
+ $(CXX) /c /nologo /TP /Fo$@ $(BASELIB_CXXFLAGS) ..\..\src\common\lzmastream.cpp
+
$(OBJS)\baselib_basemsw.obj: ..\..\src\msw\basemsw.cpp
$(CXX) /c /nologo /TP /Fo$@ $(BASELIB_CXXFLAGS) ..\..\src\msw\basemsw.cpp
diff --git a/build/msw/wx_base.vcxproj b/build/msw/wx_base.vcxproj
index bdf09a2b7d..920df8bae3 100644
--- a/build/msw/wx_base.vcxproj
+++ b/build/msw/wx_base.vcxproj
@@ -605,6 +605,7 @@
$(IntDir)common_%(Filename).obj$(IntDir)common_%(Filename).obj
+
@@ -822,6 +823,7 @@
+
diff --git a/build/msw/wx_base.vcxproj.filters b/build/msw/wx_base.vcxproj.filters
index 6e1b1cace5..30fff49b7e 100644
--- a/build/msw/wx_base.vcxproj.filters
+++ b/build/msw/wx_base.vcxproj.filters
@@ -162,6 +162,9 @@
Common Sources
+
+ Common Sources
+ Common Sources
@@ -604,6 +607,9 @@
Common Headers
+
+ Common Headers
+ Common Headers
diff --git a/build/msw/wx_vc7_base.vcproj b/build/msw/wx_vc7_base.vcproj
index 509f9cba53..007b65e75f 100644
--- a/build/msw/wx_vc7_base.vcproj
+++ b/build/msw/wx_vc7_base.vcproj
@@ -462,6 +462,9 @@
+
+
@@ -1135,6 +1138,9 @@
+
+
diff --git a/build/msw/wx_vc8_base.vcproj b/build/msw/wx_vc8_base.vcproj
index 3a22b0bd71..a2014a225b 100644
--- a/build/msw/wx_vc8_base.vcproj
+++ b/build/msw/wx_vc8_base.vcproj
@@ -1053,6 +1053,10 @@
RelativePath="..\..\src\common\longlong.cpp"
>
+
+
@@ -2111,6 +2115,10 @@
RelativePath="..\..\include\wx\longlong.h"
>
+
+
diff --git a/build/msw/wx_vc9_base.vcproj b/build/msw/wx_vc9_base.vcproj
index 2c435c44bb..7b04347201 100644
--- a/build/msw/wx_vc9_base.vcproj
+++ b/build/msw/wx_vc9_base.vcproj
@@ -1049,6 +1049,10 @@
RelativePath="..\..\src\common\longlong.cpp"
>
+
+
@@ -2107,6 +2111,10 @@
RelativePath="..\..\include\wx\longlong.h"
>
+
+
diff --git a/configure b/configure
index a8b1da5c05..42edeae0c8 100755
--- a/configure
+++ b/configure
@@ -1092,7 +1092,6 @@ with_libpng
with_libjpeg
with_libtiff
with_libjbig
-with_liblzma
with_libxpm
with_libiconv
with_libmspack
@@ -1104,6 +1103,7 @@ with_xtest
with_dmalloc
with_sdl
with_regex
+with_liblzma
with_zlib
with_expat
with_macosx_sdk
@@ -2329,7 +2329,6 @@ Optional Packages:
--with-libjpeg use libjpeg (JPEG file format)
--with-libtiff use libtiff (TIFF file format)
--without-libjbig don't use libjbig in libtiff even if available)
- --without-liblzma don't use liblzma in libtiff even if available)
--with-libxpm use libxpm (XPM file format)
--with-libiconv use libiconv (character conversion)
--with-libmspack use libmspack (CHM help files loading)
@@ -2341,6 +2340,7 @@ Optional Packages:
--with-dmalloc use dmalloc library (http://dmalloc.com/)
--with-sdl use SDL for audio on Unix
--with-regex enable support for wxRegEx class
+ --with-liblzma use LZMA compression)
--with-zlib use zlib for LZW compression
--with-expat enable XML support using expat parser
--with-macosx-sdk=PATH use an OS X SDK at PATH
@@ -3177,48 +3177,6 @@ $as_echo "$ac_res" >&6; }
} # ac_fn_c_check_type
-# ac_fn_cxx_try_run LINENO
-# ------------------------
-# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
-# that executables *can* be run.
-ac_fn_cxx_try_run ()
-{
- as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
- if { { ac_try="$ac_link"
-case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
- (eval "$ac_link") 2>&5
- ac_status=$?
- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
- test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
- { { case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
- (eval "$ac_try") 2>&5
- ac_status=$?
- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
- test $ac_status = 0; }; }; then :
- ac_retval=0
-else
- $as_echo "$as_me: program exited with status $ac_status" >&5
- $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_retval=$ac_status
-fi
- rm -rf conftest.dSYM conftest_ipa8_conftest.oo
- eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
- as_fn_set_status $ac_retval
-
-} # ac_fn_cxx_try_run
-
# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES
# -------------------------------------------------------
# Tests whether HEADER exists, giving a warning if it cannot be compiled using
@@ -3309,6 +3267,48 @@ fi
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
} # ac_fn_c_check_header_mongrel
+
+# ac_fn_cxx_try_run LINENO
+# ------------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
+# that executables *can* be run.
+ac_fn_cxx_try_run ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ if { { ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_link") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
+ { { case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_try") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; }; then :
+ ac_retval=0
+else
+ $as_echo "$as_me: program exited with status $ac_status" >&5
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_retval=$ac_status
+fi
+ rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+ as_fn_set_status $ac_retval
+
+} # ac_fn_cxx_try_run
cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
@@ -4751,7 +4751,6 @@ fi
if test "$wxUSE_LIBTIFF" = "builtin" ; then
wxUSE_LIBJBIG=no
- wxUSE_LIBLZMA=no
else
withstring=without
@@ -4782,35 +4781,6 @@ fi
eval "$wx_cv_use_libjbig"
-
- withstring=without
- defaultval=$wxUSE_ALL_FEATURES
- if test -z "$defaultval"; then
- if test x"$withstring" = xwithout; then
- defaultval=yes
- else
- defaultval=no
- fi
- fi
-
-# Check whether --with-liblzma was given.
-if test "${with_liblzma+set}" = set; then :
- withval=$with_liblzma;
- if test "$withval" = yes; then
- wx_cv_use_liblzma='wxUSE_LIBLZMA=yes'
- else
- wx_cv_use_liblzma='wxUSE_LIBLZMA=no'
- fi
-
-else
-
- wx_cv_use_liblzma='wxUSE_LIBLZMA=${'DEFAULT_wxUSE_LIBLZMA":-$defaultval}"
-
-fi
-
-
- eval "$wx_cv_use_liblzma"
-
fi
@@ -5150,6 +5120,35 @@ fi
eval "$wx_cv_use_regex"
+ withstring=
+ defaultval=$wxUSE_ALL_FEATURES
+ if test -z "$defaultval"; then
+ if test x"$withstring" = xwithout; then
+ defaultval=yes
+ else
+ defaultval=no
+ fi
+ fi
+
+# Check whether --with-liblzma was given.
+if test "${with_liblzma+set}" = set; then :
+ withval=$with_liblzma;
+ if test "$withval" = yes; then
+ wx_cv_use_liblzma='wxUSE_LIBLZMA=yes'
+ else
+ wx_cv_use_liblzma='wxUSE_LIBLZMA=no'
+ fi
+
+else
+
+ wx_cv_use_liblzma='wxUSE_LIBLZMA=${'DEFAULT_wxUSE_LIBLZMA":-$defaultval}"
+
+fi
+
+
+ eval "$wx_cv_use_liblzma"
+
+
# Check whether --with-zlib was given.
if test "${with_zlib+set}" = set; then :
@@ -23317,9 +23316,16 @@ fi
fi
-LZMA_LINK=
-if test "$wxUSE_LIBLZMA" = "yes"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for lzma_code in -llzma" >&5
+if test "$wxUSE_LIBLZMA" != "no"; then
+ ac_fn_c_check_header_mongrel "$LINENO" "lzma.h" "ac_cv_header_lzma_h" "$ac_includes_default"
+if test "x$ac_cv_header_lzma_h" = xyes; then :
+
+fi
+
+
+
+ if test "$ac_cv_header_lzma_h" = "yes"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for lzma_code in -llzma" >&5
$as_echo_n "checking for lzma_code in -llzma... " >&6; }
if ${ac_cv_lib_lzma_lzma_code+:} false; then :
$as_echo_n "(cached) " >&6
@@ -23356,10 +23362,22 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lzma_lzma_code" >&5
$as_echo "$ac_cv_lib_lzma_lzma_code" >&6; }
if test "x$ac_cv_lib_lzma_lzma_code" = xyes; then :
- LZMA_LINK=" -llzma"
+
+ LZMA_LINK="-llzma"
+ LIBS="$LZMA_LINK $LIBS"
+ $as_echo "#define wxUSE_LIBLZMA 1" >>confdefs.h
+
+
fi
-else
+ fi
+
+ if test -z "$LZMA_LINK"; then
+ wxUSE_LIBLZMA=no
+ fi
+fi
+
+if test "$HAVE_LZMA" = "no" -o "$wxUSE_LIBTIFF" = "builtin"; then
ac_configure_args="$ac_configure_args --disable-lzma"
fi
@@ -23424,7 +23442,7 @@ if test "$wxUSE_LIBTIFF" != "no" ; then
if test "$wxUSE_ZLIB" = "sys"; then
TIFF_PREREQ_LINKS="$TIFF_PREREQ_LINKS $ZLIB_LINK"
fi
- if test "$wxUSE_LIBLZMA" = "yes"; then
+ if test -n "$LZMA_LINK"; then
TIFF_PREREQ_LINKS="$TIFF_PREREQ_LINKS $LZMA_LINK"
fi
if test "$wxUSE_LIBJBIG" = "yes"; then
@@ -38925,6 +38943,11 @@ case "$wxUSE_EXPAT" in
WXCONFIG_LIBS="$EXPAT_LINK $WXCONFIG_LIBS"
;;
esac
+if test "$wxUSE_LIBLZMA" = "yes"; then
+ if test "$wxUSE_GUI" != "yes" -o "$wxUSE_LIBTIFF" != "sys"; then
+ WXCONFIG_LIBS="$LZMA_LINK $WXCONFIG_LIBS"
+ fi
+fi
case "$wxUSE_ZLIB" in
builtin)
wxconfig_3rdparty="zlib $wxconfig_3rdparty"
@@ -43251,6 +43274,7 @@ echo " tiff ${wxUSE_LIBTIFF-
if test "$wxUSE_X11" = 1 -o "$wxUSE_MOTIF" = 1; then
echo " xpm ${wxUSE_LIBXPM-none}"
fi
+echo " lzma ${wxUSE_LIBLZMA}"
echo " zlib ${wxUSE_ZLIB}"
echo " expat ${wxUSE_EXPAT}"
echo " libmspack ${wxUSE_LIBMSPACK}"
diff --git a/configure.in b/configure.in
index 0919436ef2..e0f500ce93 100644
--- a/configure.in
+++ b/configure.in
@@ -525,14 +525,12 @@ WX_ARG_SYS_WITH(libpng, [ --with-libpng use libpng (PNG image form
WX_ARG_SYS_WITH(libjpeg, [ --with-libjpeg use libjpeg (JPEG file format)], wxUSE_LIBJPEG)
WX_ARG_SYS_WITH(libtiff, [ --with-libtiff use libtiff (TIFF file format)], wxUSE_LIBTIFF)
-dnl We don't provide built-in versions of these libraries, so if the use of
-dnl system libraries is explicitly disabled, we can't use them at all.
+dnl We don't provide built-in version of this library, so if the use of system
+dnl libraries is explicitly disabled, we can't use it at all.
if test "$wxUSE_LIBTIFF" = "builtin" ; then
wxUSE_LIBJBIG=no
- wxUSE_LIBLZMA=no
else
WX_ARG_WITHOUT(libjbig, [ --without-libjbig don't use libjbig in libtiff even if available)], wxUSE_LIBJBIG)
- WX_ARG_WITHOUT(liblzma, [ --without-liblzma don't use liblzma in libtiff even if available)], wxUSE_LIBLZMA)
fi
WX_ARG_SYS_WITH(libxpm, [ --with-libxpm use libxpm (XPM file format)], wxUSE_LIBXPM)
@@ -550,6 +548,7 @@ dnl for GUI only
WX_ARG_WITH(dmalloc, [ --with-dmalloc use dmalloc library (http://dmalloc.com/)], wxUSE_DMALLOC)
WX_ARG_WITH(sdl, [ --with-sdl use SDL for audio on Unix], wxUSE_LIBSDL)
WX_ARG_SYS_WITH(regex, [ --with-regex enable support for wxRegEx class], wxUSE_REGEX)
+WX_ARG_WITH(liblzma, [ --with-liblzma use LZMA compression)], wxUSE_LIBLZMA)
WX_ARG_SYS_WITH(zlib, [ --with-zlib use zlib for LZW compression], wxUSE_ZLIB)
WX_ARG_SYS_WITH(expat, [ --with-expat enable XML support using expat parser], wxUSE_EXPAT)
@@ -2556,10 +2555,28 @@ dnl ------------------------------------------------------------------------
dnl Check for lzma library
dnl ------------------------------------------------------------------------
-LZMA_LINK=
-if test "$wxUSE_LIBLZMA" = "yes"; then
- AC_CHECK_LIB(lzma, lzma_code, LZMA_LINK=" -llzma")
-else
+if test "$wxUSE_LIBLZMA" != "no"; then
+ AC_CHECK_HEADER(lzma.h,,,[])
+
+ if test "$ac_cv_header_lzma_h" = "yes"; then
+ AC_CHECK_LIB(lzma, lzma_code,
+ [
+ LZMA_LINK="-llzma"
+ LIBS="$LZMA_LINK $LIBS"
+ AC_DEFINE(wxUSE_LIBLZMA)
+ ])
+ fi
+
+ if test -z "$LZMA_LINK"; then
+ wxUSE_LIBLZMA=no
+ fi
+fi
+
+dnl We need to disable the use of lzma in built-in libtiff explicitly, as
+dnl otherwise we'd depend on the system lzma library, which is typically
+dnl undesirable when using builtin libraries. We also disable the use of lzma
+dnl if it's not available anyhow, just to speed up libtiff configure a little.
+if test "$HAVE_LZMA" = "no" -o "$wxUSE_LIBTIFF" = "builtin"; then
ac_configure_args="$ac_configure_args --disable-lzma"
fi
@@ -2592,7 +2609,7 @@ if test "$wxUSE_LIBTIFF" != "no" ; then
if test "$wxUSE_ZLIB" = "sys"; then
TIFF_PREREQ_LINKS="$TIFF_PREREQ_LINKS $ZLIB_LINK"
fi
- if test "$wxUSE_LIBLZMA" = "yes"; then
+ if test -n "$LZMA_LINK"; then
TIFF_PREREQ_LINKS="$TIFF_PREREQ_LINKS $LZMA_LINK"
fi
if test "$wxUSE_LIBJBIG" = "yes"; then
@@ -7908,6 +7925,13 @@ case "$wxUSE_EXPAT" in
WXCONFIG_LIBS="$EXPAT_LINK $WXCONFIG_LIBS"
;;
esac
+if test "$wxUSE_LIBLZMA" = "yes"; then
+ dnl It could be already present in WXCONFIG_LIBS as tiff dependency, avoid
+ dnl adding it again in this case:
+ if test "$wxUSE_GUI" != "yes" -o "$wxUSE_LIBTIFF" != "sys"; then
+ WXCONFIG_LIBS="$LZMA_LINK $WXCONFIG_LIBS"
+ fi
+fi
case "$wxUSE_ZLIB" in
builtin)
wxconfig_3rdparty="zlib $wxconfig_3rdparty"
@@ -8389,6 +8413,7 @@ echo " tiff ${wxUSE_LIBTIFF-
if test "$wxUSE_X11" = 1 -o "$wxUSE_MOTIF" = 1; then
echo " xpm ${wxUSE_LIBXPM-none}"
fi
+echo " lzma ${wxUSE_LIBLZMA}"
echo " zlib ${wxUSE_ZLIB}"
echo " expat ${wxUSE_EXPAT}"
echo " libmspack ${wxUSE_LIBMSPACK}"
diff --git a/docs/changes.txt b/docs/changes.txt
index 7464558aa8..b9c6f3a7f3 100644
--- a/docs/changes.txt
+++ b/docs/changes.txt
@@ -72,6 +72,7 @@ Changes in behaviour which may result in build errors
All:
+- Add wxLZMA{Input,Output}Stream classes using external liblzma.
- Make wxList and wxVector iterators conform to input iterator requirements.
- Fix MT-safety problem when reading and writing from wxSocket (jkubalik).
diff --git a/docs/doxygen/mainpages/cat_classes.h b/docs/doxygen/mainpages/cat_classes.h
index 50a6485224..f48a4b032a 100644
--- a/docs/doxygen/mainpages/cat_classes.h
+++ b/docs/doxygen/mainpages/cat_classes.h
@@ -703,6 +703,8 @@ Related overview: @ref overview_stream
@li wxTempFileOutputStream: Stream to safely replace an existing file
@li wxStringInputStream: String input stream class
@li wxStringOutputStream: String output stream class
+@li wxLZMAInputStream: LZMA decompression stream class
+@li wxLZMAOutputStream: LZMA compression stream class
@li wxZlibInputStream: Zlib and gzip (compression) input stream class
@li wxZlibOutputStream: Zlib and gzip (compression) output stream class
@li wxZipInputStream: Input stream for reading from ZIP archives
diff --git a/docs/doxygen/mainpages/const_wxusedef.h b/docs/doxygen/mainpages/const_wxusedef.h
index 3753cab329..3c2040bcb8 100644
--- a/docs/doxygen/mainpages/const_wxusedef.h
+++ b/docs/doxygen/mainpages/const_wxusedef.h
@@ -148,6 +148,7 @@ library:
@itemdef{wxUSE_IPV6, Use experimental wxIPV6address and related classes.}
@itemdef{wxUSE_JOYSTICK, Use wxJoystick class.}
@itemdef{wxUSE_LIBJPEG, Enables JPEG format support (requires libjpeg).}
+@itemdef{wxUSE_LIBLZMA, Enables LZMA compression support (see @ref page_build_liblzma).}
@itemdef{wxUSE_LIBPNG, Enables PNG format support (requires libpng). Also requires wxUSE_ZLIB.}
@itemdef{wxUSE_LIBTIFF, Enables TIFF format support (requires libtiff).}
@itemdef{wxUSE_LISTBOOK, Use wxListbook class.}
diff --git a/docs/doxygen/mainpages/liblzma.h b/docs/doxygen/mainpages/liblzma.h
new file mode 100644
index 0000000000..e3d5b5d189
--- /dev/null
+++ b/docs/doxygen/mainpages/liblzma.h
@@ -0,0 +1,140 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name: liblzma.h
+// Purpose: Documentation of the use of liblzma with wxWidgets
+// Author: Vadim Zeitlin
+// Licence: wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+
+@page page_build_liblzma Using LZMA compression with liblzma
+
+To use wxLZMAInputStream and wxLZMAOutputStream classes, a public domain
+liblzma library is required when building wxWidgets. This guide explains how to
+make liblzma available and let wxWidgets build system use it. The exact steps
+depend on the operating system and compiler used, please refer to the
+section appropriate for your environment below.
+
+@section page_build_liblzma_unix Unix-like operating system (including Cygwin)
+
+Under many Unix or Unix-like (including Cygwin) systems, liblzma is available
+as a system package and the simplest thing to do is to just install it using
+the system-specific tool (apt, yum, ...). Just note that you need to install
+the liblzma-dev or liblzma-devel package in order to obtain the library headers
+and not just the library itself.
+
+If your system doesn't provide such package or you need to use a newer version
+than is available in the system repositories, it is also simple to build
+liblzma from sources: basically, just download the library sources from
+https://tukaani.org/xz/ or clone its repository and perform the usual
+
+@code
+ $ ./configure
+ $ make
+ $ make install
+@endcode
+
+commands sequence.
+
+As wxWidgets is built using either configure or CMake under Unix-like systems,
+there is nothing special to do to let wxWidgets use liblzma, as it will be
+detected automatically -- just check the end of configure or CMake output to
+confirm that it was found. If this is not the case because the library was
+installed in some non-default location, you need to provide @c CPPFLAGS and @c
+LDFLAGS on configure command line, e.g.:
+
+@code
+ $ ../configure CPPFLAGS=-I/opt/liblzma/include LDFLAGS=-L/opt/liblzma/lib
+@endcode
+
+
+@section page_build_liblzma_msw MSW not using configure
+
+When not using configure, you must edit @c wx/msw/setup.h file and change the
+value of @c wxUSE_LIBLZMA option to @c 1 manually in order to enable LZMA
+support, which is disabled by default.
+
+Next, you need to actually ensure that the library is available to be able to
+build wxWidgets:
+
+@subsection page_build_liblzma_msw_vcpkg MSW using MSVS 2015 with Vcpkg
+
+If you build wxWidgets with Microsoft Visual Studio 2015.3 or later, you can
+use Microsoft vcpkg tool (see https://github.com/Microsoft/vcpkg) to install
+liblzma as any other library and integrate it with Microsoft Visual Studio
+automatically. Please see vcpkg documentation for details, but, basically, it's
+as simple as executing the following commands:
+
+@code
+ > git clone https://github.com/Microsoft/vcpkg.git
+ > cd vcpkg
+ > .\bootstrap-vcpkg.bat
+ > .\vcpkg integrate install
+ > .\vcpkg install liblzma
+@endcode
+
+Afterwards, liblzma headers and libraries (in DLL form) will be available to
+all C++ Visual Studio projects, including wxWidgets, so you just need to build
+it as usual, i.e. by opening @c build/msw/wx_vcXX.sln file and building it.
+
+
+@section page_build_liblzma_msw_manual MSW manual setup
+
+First of all, you need to either build or download liblzma binaries. Building
+the library from source with gcc requires configure, and as you don't use an
+environment capable of running it (if you're, you're reading the wrong section
+of this guide, please go to the first one instead), it might be simpler to just
+download the binaries from https://tukaani.org/xz/
+
+However these binaries don't provide import libraries for MSVC, so you may
+prefer building from source when using this compiler, provided it is at least
+2013.2 or later (otherwise, you must use the binaries and create the import
+library from the DLL). To do it, simply open the MSVS solution provided under
+@c windows directory of the source archive corresponding to your compiler
+version and build all the relevant configurations. Notice that you may build it
+as either a static or a dynamic library, but if you choose the former, you must
+also predefine @c LZMA_API_STATIC when building wxWidgets.
+
+
+Second, you need to let wxWidgets build system know about the liblzma headers
+and libraries location. When using makefiles, with either gcc or MSVC compiler,
+this can be done simply by specifying @c CPPFLAGS and @c LDFLAGS on make
+command line, e.g.
+
+@code
+ > make -f makefile.gcc CPPFLAGS=-Ic:/dev/include LDFLAGS=-Lc:/dev/lib
+@endcode
+
+If you built liblzma as a static library, change @c CPPFLAGS to also include @c
+-DLZMA_API_STATIC.
+
+
+When building wxWidgets with MSVC project files, you must update them to use
+liblzma. For this, start by copying build\\msw\\wx_setup.props file to
+build\\msw\\wx_local.props, if you don't have the latter file yet. Then open
+this file in your favourite editor and locate the @c Link tag inside an @c
+ItemDefinitionGroup tag and add a new @c AdditionalIncludeDirectories line
+inside the @c ClCompile tag as well as add @c liblzma.lib to the @c
+AdditionalDependencies tag under @c Link itself. The result should look like
+the following, assuming liblzma sources are in c:\\src\\liblzma:
+
+@code
+
+
+ ... any existing lines here ...
+ c:\src\liblzma\src\liblzma\api;%(AdditionalIncludeDirectories)
+
+
+
+ ... all the previously listed libraries;c:\src\liblzma\windows\vs2017\$(Configuration)\$(Platform)\liblzma_dll\liblzma.lib;%(AdditionalDependencies)
+
+
+@endcode
+
+Afterwards, build wxWidgets as usual and don't forget to provide @c liblzma.dll
+when distributing your application unless you have decided to link it
+statically.
+ */
diff --git a/include/wx/android/setup.h b/include/wx/android/setup.h
index 8ca861908e..ccc99e7ad0 100644
--- a/include/wx/android/setup.h
+++ b/include/wx/android/setup.h
@@ -610,6 +610,22 @@
// wxUSE_LIBPNG
#define wxUSE_ZLIB 1
+// Set to 1 if liblzma is available to enable wxLZMA{Input,Output}Stream
+// classes.
+//
+// Notice that if you enable this build option when not using configure or
+// CMake, you need to ensure that liblzma headers and libraries are available
+// (i.e. by building the library yourself or downloading its binaries) and can
+// be found, either by copying them to one of the locations searched by the
+// compiler/linker by default (e.g. any of the directories in the INCLUDE or
+// LIB environment variables, respectively, when using MSVC) or modify the
+// make- or project files to add references to these directories.
+//
+// Default is 0 under MSW, auto-detected by configure.
+//
+// Recommended setting: 1 if you need LZMA compression.
+#define wxUSE_LIBLZMA 0
+
// If enabled, the code written by Apple will be used to write, in a portable
// way, float on the disk. See extended.c for the license which is different
// from wxWidgets one.
diff --git a/include/wx/gtk/setup0.h b/include/wx/gtk/setup0.h
index df78b80ef3..22ee07b8d0 100644
--- a/include/wx/gtk/setup0.h
+++ b/include/wx/gtk/setup0.h
@@ -611,6 +611,22 @@
// wxUSE_LIBPNG
#define wxUSE_ZLIB 1
+// Set to 1 if liblzma is available to enable wxLZMA{Input,Output}Stream
+// classes.
+//
+// Notice that if you enable this build option when not using configure or
+// CMake, you need to ensure that liblzma headers and libraries are available
+// (i.e. by building the library yourself or downloading its binaries) and can
+// be found, either by copying them to one of the locations searched by the
+// compiler/linker by default (e.g. any of the directories in the INCLUDE or
+// LIB environment variables, respectively, when using MSVC) or modify the
+// make- or project files to add references to these directories.
+//
+// Default is 0 under MSW, auto-detected by configure.
+//
+// Recommended setting: 1 if you need LZMA compression.
+#define wxUSE_LIBLZMA 0
+
// If enabled, the code written by Apple will be used to write, in a portable
// way, float on the disk. See extended.c for the license which is different
// from wxWidgets one.
diff --git a/include/wx/lzmastream.h b/include/wx/lzmastream.h
new file mode 100644
index 0000000000..9bd2ab1bab
--- /dev/null
+++ b/include/wx/lzmastream.h
@@ -0,0 +1,149 @@
+///////////////////////////////////////////////////////////////////////////////
+// Name: wx/lzmastream.h
+// Purpose: Filters streams using LZMA(2) compression
+// Author: Vadim Zeitlin
+// Created: 2018-03-29
+// Copyright: (c) 2018 Vadim Zeitlin
+// Licence: wxWindows licence
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_LZMASTREAM_H_
+#define _WX_LZMASTREAM_H_
+
+#include "wx/defs.h"
+
+#if wxUSE_LIBLZMA && wxUSE_STREAMS
+
+#include "wx/stream.h"
+#include "wx/versioninfo.h"
+
+namespace wxPrivate
+{
+
+// Private wrapper for lzma_stream struct.
+struct wxLZMAStream;
+
+// Common part of input and output LZMA streams: this is just an implementation
+// detail and is not part of the public API.
+class WXDLLIMPEXP_BASE wxLZMAData
+{
+protected:
+ wxLZMAData();
+ ~wxLZMAData();
+
+ wxLZMAStream* m_stream;
+ wxUint8* m_streamBuf;
+ wxFileOffset m_pos;
+
+ wxDECLARE_NO_COPY_CLASS(wxLZMAData);
+};
+
+} // namespace wxPrivate
+
+// ----------------------------------------------------------------------------
+// Filter for decompressing data compressed using LZMA
+// ----------------------------------------------------------------------------
+
+class WXDLLIMPEXP_BASE wxLZMAInputStream : public wxFilterInputStream,
+ private wxPrivate::wxLZMAData
+{
+public:
+ explicit wxLZMAInputStream(wxInputStream& stream)
+ : wxFilterInputStream(stream)
+ {
+ Init();
+ }
+
+ explicit wxLZMAInputStream(wxInputStream* stream)
+ : wxFilterInputStream(stream)
+ {
+ Init();
+ }
+
+ char Peek() wxOVERRIDE { return wxInputStream::Peek(); }
+ wxFileOffset GetLength() const wxOVERRIDE { return wxInputStream::GetLength(); }
+
+protected:
+ size_t OnSysRead(void *buffer, size_t size) wxOVERRIDE;
+ wxFileOffset OnSysTell() const wxOVERRIDE { return m_pos; }
+
+private:
+ void Init();
+};
+
+// ----------------------------------------------------------------------------
+// Filter for compressing data using LZMA(2) algorithm
+// ----------------------------------------------------------------------------
+
+class WXDLLIMPEXP_BASE wxLZMAOutputStream : public wxFilterOutputStream,
+ private wxPrivate::wxLZMAData
+{
+public:
+ explicit wxLZMAOutputStream(wxOutputStream& stream, int level = -1)
+ : wxFilterOutputStream(stream)
+ {
+ Init(level);
+ }
+
+ explicit wxLZMAOutputStream(wxOutputStream* stream, int level = -1)
+ : wxFilterOutputStream(stream)
+ {
+ Init(level);
+ }
+
+ virtual ~wxLZMAOutputStream() { Close(); }
+
+ void Sync() wxOVERRIDE { DoFlush(false); }
+ bool Close() wxOVERRIDE;
+ wxFileOffset GetLength() const wxOVERRIDE { return m_pos; }
+
+protected:
+ size_t OnSysWrite(const void *buffer, size_t size) wxOVERRIDE;
+ wxFileOffset OnSysTell() const wxOVERRIDE { return m_pos; }
+
+private:
+ void Init(int level);
+
+ // Write the contents of the internal buffer to the output stream.
+ bool UpdateOutput();
+
+ // Write out the current buffer if necessary, i.e. if no space remains in
+ // it, and reinitialize m_stream to point to it. Returns false on success
+ // or false on error, in which case m_lasterror is updated.
+ bool UpdateOutputIfNecessary();
+
+ // Run LZMA_FINISH (if argument is true) or LZMA_FULL_FLUSH, return true on
+ // success or false on error.
+ bool DoFlush(bool finish);
+};
+
+// ----------------------------------------------------------------------------
+// Support for creating LZMA streams from extension/MIME type
+// ----------------------------------------------------------------------------
+
+class WXDLLIMPEXP_BASE wxLZMAClassFactory: public wxFilterClassFactory
+{
+public:
+ wxLZMAClassFactory();
+
+ wxFilterInputStream *NewStream(wxInputStream& stream) const wxOVERRIDE
+ { return new wxLZMAInputStream(stream); }
+ wxFilterOutputStream *NewStream(wxOutputStream& stream) const wxOVERRIDE
+ { return new wxLZMAOutputStream(stream, -1); }
+ wxFilterInputStream *NewStream(wxInputStream *stream) const wxOVERRIDE
+ { return new wxLZMAInputStream(stream); }
+ wxFilterOutputStream *NewStream(wxOutputStream *stream) const wxOVERRIDE
+ { return new wxLZMAOutputStream(stream, -1); }
+
+ const wxChar * const *GetProtocols(wxStreamProtocolType type
+ = wxSTREAM_PROTOCOL) const wxOVERRIDE;
+
+private:
+ wxDECLARE_DYNAMIC_CLASS(wxLZMAClassFactory);
+};
+
+WXDLLIMPEXP_BASE wxVersionInfo wxGetLibLZMAVersionInfo();
+
+#endif // wxUSE_LIBLZMA && wxUSE_STREAMS
+
+#endif // _WX_LZMASTREAM_H_
diff --git a/include/wx/motif/setup0.h b/include/wx/motif/setup0.h
index 048281ec70..fc4c657c01 100644
--- a/include/wx/motif/setup0.h
+++ b/include/wx/motif/setup0.h
@@ -611,6 +611,22 @@
// wxUSE_LIBPNG
#define wxUSE_ZLIB 1
+// Set to 1 if liblzma is available to enable wxLZMA{Input,Output}Stream
+// classes.
+//
+// Notice that if you enable this build option when not using configure or
+// CMake, you need to ensure that liblzma headers and libraries are available
+// (i.e. by building the library yourself or downloading its binaries) and can
+// be found, either by copying them to one of the locations searched by the
+// compiler/linker by default (e.g. any of the directories in the INCLUDE or
+// LIB environment variables, respectively, when using MSVC) or modify the
+// make- or project files to add references to these directories.
+//
+// Default is 0 under MSW, auto-detected by configure.
+//
+// Recommended setting: 1 if you need LZMA compression.
+#define wxUSE_LIBLZMA 0
+
// If enabled, the code written by Apple will be used to write, in a portable
// way, float on the disk. See extended.c for the license which is different
// from wxWidgets one.
diff --git a/include/wx/msw/setup0.h b/include/wx/msw/setup0.h
index bd082d170c..dcbb2d7fde 100644
--- a/include/wx/msw/setup0.h
+++ b/include/wx/msw/setup0.h
@@ -611,6 +611,22 @@
// wxUSE_LIBPNG
#define wxUSE_ZLIB 1
+// Set to 1 if liblzma is available to enable wxLZMA{Input,Output}Stream
+// classes.
+//
+// Notice that if you enable this build option when not using configure or
+// CMake, you need to ensure that liblzma headers and libraries are available
+// (i.e. by building the library yourself or downloading its binaries) and can
+// be found, either by copying them to one of the locations searched by the
+// compiler/linker by default (e.g. any of the directories in the INCLUDE or
+// LIB environment variables, respectively, when using MSVC) or modify the
+// make- or project files to add references to these directories.
+//
+// Default is 0 under MSW, auto-detected by configure.
+//
+// Recommended setting: 1 if you need LZMA compression.
+#define wxUSE_LIBLZMA 0
+
// If enabled, the code written by Apple will be used to write, in a portable
// way, float on the disk. See extended.c for the license which is different
// from wxWidgets one.
diff --git a/include/wx/osx/setup0.h b/include/wx/osx/setup0.h
index 3f6b48c69c..a1307bf4d4 100644
--- a/include/wx/osx/setup0.h
+++ b/include/wx/osx/setup0.h
@@ -617,6 +617,22 @@
// wxUSE_LIBPNG
#define wxUSE_ZLIB 1
+// Set to 1 if liblzma is available to enable wxLZMA{Input,Output}Stream
+// classes.
+//
+// Notice that if you enable this build option when not using configure or
+// CMake, you need to ensure that liblzma headers and libraries are available
+// (i.e. by building the library yourself or downloading its binaries) and can
+// be found, either by copying them to one of the locations searched by the
+// compiler/linker by default (e.g. any of the directories in the INCLUDE or
+// LIB environment variables, respectively, when using MSVC) or modify the
+// make- or project files to add references to these directories.
+//
+// Default is 0 under MSW, auto-detected by configure.
+//
+// Recommended setting: 1 if you need LZMA compression.
+#define wxUSE_LIBLZMA 0
+
// If enabled, the code written by Apple will be used to write, in a portable
// way, float on the disk. See extended.c for the license which is different
// from wxWidgets one.
diff --git a/include/wx/setup_inc.h b/include/wx/setup_inc.h
index a58ec282f1..bece6430b8 100644
--- a/include/wx/setup_inc.h
+++ b/include/wx/setup_inc.h
@@ -607,6 +607,22 @@
// wxUSE_LIBPNG
#define wxUSE_ZLIB 1
+// Set to 1 if liblzma is available to enable wxLZMA{Input,Output}Stream
+// classes.
+//
+// Notice that if you enable this build option when not using configure or
+// CMake, you need to ensure that liblzma headers and libraries are available
+// (i.e. by building the library yourself or downloading its binaries) and can
+// be found, either by copying them to one of the locations searched by the
+// compiler/linker by default (e.g. any of the directories in the INCLUDE or
+// LIB environment variables, respectively, when using MSVC) or modify the
+// make- or project files to add references to these directories.
+//
+// Default is 0 under MSW, auto-detected by configure.
+//
+// Recommended setting: 1 if you need LZMA compression.
+#define wxUSE_LIBLZMA 0
+
// If enabled, the code written by Apple will be used to write, in a portable
// way, float on the disk. See extended.c for the license which is different
// from wxWidgets one.
diff --git a/include/wx/univ/setup0.h b/include/wx/univ/setup0.h
index 7544890848..11c7277097 100644
--- a/include/wx/univ/setup0.h
+++ b/include/wx/univ/setup0.h
@@ -610,6 +610,22 @@
// wxUSE_LIBPNG
#define wxUSE_ZLIB 1
+// Set to 1 if liblzma is available to enable wxLZMA{Input,Output}Stream
+// classes.
+//
+// Notice that if you enable this build option when not using configure or
+// CMake, you need to ensure that liblzma headers and libraries are available
+// (i.e. by building the library yourself or downloading its binaries) and can
+// be found, either by copying them to one of the locations searched by the
+// compiler/linker by default (e.g. any of the directories in the INCLUDE or
+// LIB environment variables, respectively, when using MSVC) or modify the
+// make- or project files to add references to these directories.
+//
+// Default is 0 under MSW, auto-detected by configure.
+//
+// Recommended setting: 1 if you need LZMA compression.
+#define wxUSE_LIBLZMA 0
+
// If enabled, the code written by Apple will be used to write, in a portable
// way, float on the disk. See extended.c for the license which is different
// from wxWidgets one.
diff --git a/interface/wx/lzmastream.h b/interface/wx/lzmastream.h
new file mode 100644
index 0000000000..0b59499aa0
--- /dev/null
+++ b/interface/wx/lzmastream.h
@@ -0,0 +1,116 @@
+///////////////////////////////////////////////////////////////////////////////
+// Name: wx/lzmastream.h
+// Purpose: LZMA [de]compression classes documentation
+// Author: Vadim Zeitlin
+// Created: 2018-03-29
+// Copyright: (c) 2018 Vadim Zeitlin
+// Licence: wxWindows licence
+///////////////////////////////////////////////////////////////////////////////
+
+/**
+ @class wxLZMAInputStream
+
+ This filter stream decompresses data in XZ format.
+
+ XZ format uses LZMA2 algorithm for compression used for .xz files and is
+ similar to GZip or BZip2 format. Notice that it is different from, and
+ incompatible with, 7z archive format even although it uses the same
+ compression algorithm.
+
+ To decompress contents of standard input to standard output, the following
+ (not optimally efficient) code could be used:
+ @code
+ wxFFileInputStream fin(stdin);
+ wxLZMAInputStream zin(fin);
+ wxFFileOutputStream fout(stdout);
+ zin.Read(fout);
+
+ if ( zin.GetLastError() != wxSTREAM_EOF ) {
+ ... handle error ...
+ }
+ @endcode
+
+ See @ref page_build_liblzma for information about liblzma, required in
+ order to use this class.
+
+ @library{wxbase}
+ @category{archive,streams}
+
+ @see wxInputStream, wxZlibInputStream, wxLZMAOutputStream.
+
+ @since 3.1.2
+*/
+class wxLZMAInputStream : public wxFilterInputStream
+{
+public:
+ /**
+ Create decompressing stream associated with the given underlying
+ stream.
+
+ This overload does not take ownership of the @a stream.
+ */
+ wxLZMAInputStream(wxInputStream& stream);
+
+ /**
+ Create decompressing stream associated with the given underlying
+ stream and takes ownership of it.
+
+ As with the base wxFilterInputStream class, passing @a stream by
+ pointer indicates that this object takes ownership of it and will
+ delete it when it is itself destroyed.
+ */
+ wxLZMAInputStream(wxInputStream* stream);
+};
+
+/**
+ @class wxLZMAOutputStream
+
+ This filter stream compresses data using XZ format.
+
+ XZ format uses LZMA compression, making it (significantly) more efficient
+ than Gzip format used by wxZlibOutputStream. Output generated by this class
+ is compatible with xz utilities working with .xz files and also supported
+ by 7-Zip program, even though it is different from its native .7z format.
+
+ See @ref page_build_liblzma for information about liblzma, required in
+ order to use this class.
+
+ @library{wxbase}
+ @category{archive,streams}
+
+ @see wxOutputStream, wxZlibOutputStream, wxLZMAInputStream
+
+ @since 3.1.2
+*/
+class wxLZMAOutputStream : public wxFilterOutputStream
+{
+ /**
+ Create compressing stream associated with the given underlying
+ stream.
+
+ This overload does not take ownership of the @a stream.
+ */
+ wxLZMAOutputStream(wxOutputStream& stream);
+
+ /**
+ Create compressing stream associated with the given underlying
+ stream and takes ownership of it.
+
+ As with the base wxFilterOutputStream class, passing @a stream by
+ pointer indicates that this object takes ownership of it and will
+ delete it when it is itself destroyed.
+ */
+ wxLZMAOutputStream(wxOutputStream* stream);
+};
+
+/**
+ Return the version of liblzma library used by LZMA stream classes.
+
+ @see wxVersionInfo
+
+ @header{wx/lzmastream.h}
+ @library{wxbase}
+
+ @since 3.1.2
+*/
+wxVersionInfo wxGetLibLZMAVersionInfo();
diff --git a/setup.h.in b/setup.h.in
index 981b45e1da..9f703405c1 100644
--- a/setup.h.in
+++ b/setup.h.in
@@ -287,6 +287,8 @@
#define wxUSE_ZLIB 0
+#define wxUSE_LIBLZMA 0
+
#define wxUSE_APPLE_IEEE 0
#define wxUSE_JOYSTICK 0
diff --git a/src/common/lzmastream.cpp b/src/common/lzmastream.cpp
new file mode 100644
index 0000000000..7c4c62a335
--- /dev/null
+++ b/src/common/lzmastream.cpp
@@ -0,0 +1,405 @@
+///////////////////////////////////////////////////////////////////////////////
+// Name: src/common/lzmastream.cpp
+// Purpose: Implementation of LZMA stream classes
+// Author: Vadim Zeitlin
+// Created: 2018-03-29
+// Copyright: (c) 2018 Vadim Zeitlin
+// Licence: wxWindows licence
+///////////////////////////////////////////////////////////////////////////////
+
+// ============================================================================
+// declarations
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
+
+// for compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+#if wxUSE_LIBLZMA && wxUSE_STREAMS
+
+#include "wx/lzmastream.h"
+
+#ifndef WX_PRECOMP
+ #include "wx/log.h"
+ #include "wx/translation.h"
+#endif // WX_PRECOMP
+
+#include
+
+namespace wxPrivate
+{
+
+// ----------------------------------------------------------------------------
+// Constants
+// ----------------------------------------------------------------------------
+
+const size_t wxLZMA_BUF_SIZE = 4096;
+
+// ----------------------------------------------------------------------------
+// Private helpers
+// ----------------------------------------------------------------------------
+
+// Simpler wrapper around lzma_stream, taking care of initializing and
+// finalizing it.
+struct wxLZMAStream : lzma_stream
+{
+ wxLZMAStream()
+ {
+ memset(this, 0, sizeof(lzma_stream));
+ }
+
+ ~wxLZMAStream()
+ {
+ lzma_end(this);
+ }
+};
+
+} // namespace wxPrivate
+
+using namespace wxPrivate;
+
+// ============================================================================
+// implementation
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// Functions
+// ----------------------------------------------------------------------------
+
+wxVersionInfo wxGetLibLZMAVersionInfo()
+{
+ const uint32_t ver = lzma_version_number();
+
+ // For now ignore the "stability" part of the version.
+ return wxVersionInfo
+ (
+ "liblzma",
+ ver / 10000000,
+ (ver % 10000000) / 10000,
+ (ver % 10000) / 10
+ );
+}
+
+// ----------------------------------------------------------------------------
+// wxLZMAData: common helpers for compression and decompression
+// ----------------------------------------------------------------------------
+
+wxLZMAData::wxLZMAData()
+{
+ m_stream = new wxLZMAStream;
+ m_streamBuf = new wxUint8[wxLZMA_BUF_SIZE];
+ m_pos = 0;
+}
+
+wxLZMAData::~wxLZMAData()
+{
+ delete [] m_streamBuf;
+ delete m_stream;
+}
+
+// ----------------------------------------------------------------------------
+// wxLZMAInputStream: decompression
+// ----------------------------------------------------------------------------
+
+void wxLZMAInputStream::Init()
+{
+ // We don't specify any memory usage limit nor any flags, not even
+ // LZMA_CONCATENATED recommended by liblzma documentation, because we don't
+ // foresee the need to support concatenated compressed files for now.
+ const lzma_ret rc = lzma_stream_decoder(m_stream, UINT64_MAX, 0);
+ switch ( rc )
+ {
+ case LZMA_OK:
+ // Skip setting m_lasterror below.
+ return;
+
+ case LZMA_MEM_ERROR:
+ wxLogError(_("Failed to allocate memory for LZMA decompression."));
+ break;
+
+ default:
+ wxLogError(_("Failed to initialize LZMA decompression: "
+ "unexpected error %u."),
+ rc);
+ break;
+ }
+
+ m_lasterror = wxSTREAM_READ_ERROR;
+}
+
+size_t wxLZMAInputStream::OnSysRead(void* outbuf, size_t size)
+{
+ m_stream->next_out = static_cast(outbuf);
+ m_stream->avail_out = size;
+
+ // Decompress input as long as we don't have any errors (including EOF, as
+ // it doesn't make sense to continue after it neither) and have space to
+ // decompress it to.
+ while ( m_lasterror == wxSTREAM_NO_ERROR && m_stream->avail_out > 0 )
+ {
+ // Get more input data if needed.
+ if ( !m_stream->avail_in )
+ {
+ m_parent_i_stream->Read(m_streamBuf, wxLZMA_BUF_SIZE);
+ m_stream->next_in = m_streamBuf;
+ m_stream->avail_in = m_parent_i_stream->LastRead();
+
+ if ( !m_stream->avail_in )
+ {
+ if ( m_parent_i_stream->GetLastError() == wxSTREAM_EOF )
+ {
+ // We have reached end of the underlying stream.
+ m_lasterror = wxSTREAM_EOF;
+ break;
+ }
+
+ m_lasterror = wxSTREAM_READ_ERROR;
+ return 0;
+ }
+ }
+
+ // Do decompress.
+ const lzma_ret rc = lzma_code(m_stream, LZMA_RUN);
+
+ wxString err;
+ switch ( rc )
+ {
+ case LZMA_OK:
+ continue;
+
+ case LZMA_STREAM_END:
+ m_lasterror = wxSTREAM_EOF;
+ continue;
+
+ case LZMA_FORMAT_ERROR:
+ err = wxTRANSLATE("input is not in XZ format");
+ break;
+
+ case LZMA_OPTIONS_ERROR:
+ err = wxTRANSLATE("input compressed using unknown XZ option");
+ break;
+
+ case LZMA_DATA_ERROR:
+ case LZMA_BUF_ERROR:
+ err = wxTRANSLATE("input is corrupted");
+ break;
+
+ default:
+ err = wxTRANSLATE("unknown decompression error");
+ break;
+ }
+
+ wxLogError(_("LZMA decompression error: %s"), wxGetTranslation(err));
+
+ m_lasterror = wxSTREAM_READ_ERROR;
+ return 0;
+ }
+
+ // Return the number of bytes actually read, this may be less than the
+ // requested size if we hit EOF.
+ size -= m_stream->avail_out;
+ m_pos += size;
+ return size;
+}
+
+// ----------------------------------------------------------------------------
+// wxLZMAOutputStream: compression
+// ----------------------------------------------------------------------------
+
+void wxLZMAOutputStream::Init(int level)
+{
+ if ( level == -1 )
+ level = LZMA_PRESET_DEFAULT;
+
+ // Use the check type recommended by liblzma documentation.
+ const lzma_ret rc = lzma_easy_encoder(m_stream, level, LZMA_CHECK_CRC64);
+ switch ( rc )
+ {
+ case LZMA_OK:
+ // Prepare for the first call to OnSysWrite().
+ m_stream->next_out = m_streamBuf;
+ m_stream->avail_out = wxLZMA_BUF_SIZE;
+
+ // Skip setting m_lasterror below.
+ return;
+
+ case LZMA_MEM_ERROR:
+ wxLogError(_("Failed to allocate memory for LZMA compression."));
+ break;
+
+ default:
+ wxLogError(_("Failed to initialize LZMA compression: "
+ "unexpected error %u."),
+ rc);
+ break;
+ }
+
+ m_lasterror = wxSTREAM_WRITE_ERROR;
+}
+
+size_t wxLZMAOutputStream::OnSysWrite(const void *inbuf, size_t size)
+{
+ m_stream->next_in = static_cast(inbuf);
+ m_stream->avail_in = size;
+
+ // Compress as long as we have any input data, but stop at first error as
+ // it's useless to try to continue after it (or even starting if the stream
+ // had already been in an error state).
+ while ( m_lasterror == wxSTREAM_NO_ERROR && m_stream->avail_in > 0 )
+ {
+ // Flush the output buffer if necessary.
+ if ( !UpdateOutputIfNecessary() )
+ return 0;
+
+ const lzma_ret rc = lzma_code(m_stream, LZMA_RUN);
+
+ wxString err;
+ switch ( rc )
+ {
+ case LZMA_OK:
+ continue;
+
+ case LZMA_MEM_ERROR:
+ err = wxTRANSLATE("out of memory");
+ break;
+
+ case LZMA_STREAM_END:
+ // This is unexpected as we don't use LZMA_FINISH here.
+ wxFAIL_MSG( "Unexpected LZMA stream end" );
+ wxFALLTHROUGH;
+
+ default:
+ err = wxTRANSLATE("unknown compression error");
+ break;
+ }
+
+ wxLogError(_("LZMA compression error: %s"), wxGetTranslation(err));
+
+ m_lasterror = wxSTREAM_WRITE_ERROR;
+ return 0;
+ }
+
+ m_pos += size;
+ return size;
+}
+
+bool wxLZMAOutputStream::UpdateOutput()
+{
+ // Write the buffer contents to the real output, taking care only to write
+ // as much of it as we actually have, as the buffer can (and very likely
+ // will) be incomplete.
+ const size_t numOut = wxLZMA_BUF_SIZE - m_stream->avail_out;
+ m_parent_o_stream->Write(m_streamBuf, numOut);
+ if ( m_parent_o_stream->LastWrite() != numOut )
+ {
+ m_lasterror = wxSTREAM_WRITE_ERROR;
+ return false;
+ }
+
+ return true;
+}
+
+bool wxLZMAOutputStream::UpdateOutputIfNecessary()
+{
+ if ( !m_stream->avail_out )
+ {
+ if ( !UpdateOutput() )
+ return false;
+
+ m_stream->next_out = m_streamBuf;
+ m_stream->avail_out = wxLZMA_BUF_SIZE;
+ }
+
+ return true;
+}
+
+bool wxLZMAOutputStream::DoFlush(bool finish)
+{
+ const lzma_action action = finish ? LZMA_FINISH : LZMA_FULL_FLUSH;
+
+ while ( m_lasterror == wxSTREAM_NO_ERROR )
+ {
+ if ( !UpdateOutputIfNecessary() )
+ break;
+
+ const lzma_ret rc = lzma_code(m_stream, action);
+
+ wxString err;
+ switch ( rc )
+ {
+ case LZMA_OK:
+ continue;
+
+ case LZMA_STREAM_END:
+ // Don't forget to output the last part of the data.
+ return UpdateOutput();
+
+ case LZMA_MEM_ERROR:
+ err = wxTRANSLATE("out of memory");
+
+ default:
+ err = wxTRANSLATE("unknown compression error");
+ break;
+ }
+
+ wxLogError(_("LZMA compression error when flushing output: %s"),
+ wxGetTranslation(err));
+
+ m_lasterror = wxSTREAM_WRITE_ERROR;
+ }
+
+ return false;
+}
+
+bool wxLZMAOutputStream::Close()
+{
+ if ( !DoFlush(true) )
+ return false;
+
+ m_stream->next_out = m_streamBuf;
+ m_stream->avail_out = wxLZMA_BUF_SIZE;
+
+ return wxFilterOutputStream::Close() && IsOk();
+}
+
+// ----------------------------------------------------------------------------
+// wxLZMAClassFactory: allow creating streams from extension/MIME type
+// ----------------------------------------------------------------------------
+
+wxIMPLEMENT_DYNAMIC_CLASS(wxLZMAClassFactory, wxFilterClassFactory);
+
+static wxLZMAClassFactory g_wxLZMAClassFactory;
+
+wxLZMAClassFactory::wxLZMAClassFactory()
+{
+ if ( this == &g_wxLZMAClassFactory )
+ PushFront();
+}
+
+const wxChar * const *
+wxLZMAClassFactory::GetProtocols(wxStreamProtocolType type) const
+{
+ static const wxChar *mime[] = { wxT("application/xz"), NULL };
+ static const wxChar *encs[] = { wxT("xz"), NULL };
+ static const wxChar *exts[] = { wxT(".xz"), NULL };
+
+ const wxChar* const* ret = NULL;
+ switch ( type )
+ {
+ case wxSTREAM_PROTOCOL: ret = encs; break;
+ case wxSTREAM_MIMETYPE: ret = mime; break;
+ case wxSTREAM_ENCODING: ret = encs; break;
+ case wxSTREAM_FILEEXT: ret = exts; break;
+ }
+
+ return ret;
+}
+
+#endif // wxUSE_LIBLZMA && wxUSE_STREAMS
diff --git a/tests/Makefile.in b/tests/Makefile.in
index 69d960b891..d20559e8fe 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -120,6 +120,7 @@ TEST_OBJECTS = \
test_filestream.o \
test_iostreams.o \
test_largefile.o \
+ test_lzmastream.o \
test_memstream.o \
test_socketstream.o \
test_sstream.o \
@@ -687,6 +688,9 @@ test_iostreams.o: $(srcdir)/streams/iostreams.cpp $(TEST_ODEP)
test_largefile.o: $(srcdir)/streams/largefile.cpp $(TEST_ODEP)
$(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/streams/largefile.cpp
+test_lzmastream.o: $(srcdir)/streams/lzmastream.cpp $(TEST_ODEP)
+ $(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/streams/lzmastream.cpp
+
test_memstream.o: $(srcdir)/streams/memstream.cpp $(TEST_ODEP)
$(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/streams/memstream.cpp
diff --git a/tests/makefile.bcc b/tests/makefile.bcc
index 25f9fc68d1..30897885eb 100644
--- a/tests/makefile.bcc
+++ b/tests/makefile.bcc
@@ -102,6 +102,7 @@ TEST_OBJECTS = \
$(OBJS)\test_filestream.obj \
$(OBJS)\test_iostreams.obj \
$(OBJS)\test_largefile.obj \
+ $(OBJS)\test_lzmastream.obj \
$(OBJS)\test_memstream.obj \
$(OBJS)\test_socketstream.obj \
$(OBJS)\test_sstream.obj \
@@ -734,6 +735,9 @@ $(OBJS)\test_iostreams.obj: .\streams\iostreams.cpp
$(OBJS)\test_largefile.obj: .\streams\largefile.cpp
$(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) .\streams\largefile.cpp
+$(OBJS)\test_lzmastream.obj: .\streams\lzmastream.cpp
+ $(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) .\streams\lzmastream.cpp
+
$(OBJS)\test_memstream.obj: .\streams\memstream.cpp
$(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) .\streams\memstream.cpp
diff --git a/tests/makefile.gcc b/tests/makefile.gcc
index c6971bac0b..b9a05edb64 100644
--- a/tests/makefile.gcc
+++ b/tests/makefile.gcc
@@ -94,6 +94,7 @@ TEST_OBJECTS = \
$(OBJS)\test_filestream.o \
$(OBJS)\test_iostreams.o \
$(OBJS)\test_largefile.o \
+ $(OBJS)\test_lzmastream.o \
$(OBJS)\test_memstream.o \
$(OBJS)\test_socketstream.o \
$(OBJS)\test_sstream.o \
@@ -711,6 +712,9 @@ $(OBJS)\test_iostreams.o: ./streams/iostreams.cpp
$(OBJS)\test_largefile.o: ./streams/largefile.cpp
$(CXX) -c -o $@ $(TEST_CXXFLAGS) $(CPPDEPS) $<
+$(OBJS)\test_lzmastream.o: ./streams/lzmastream.cpp
+ $(CXX) -c -o $@ $(TEST_CXXFLAGS) $(CPPDEPS) $<
+
$(OBJS)\test_memstream.o: ./streams/memstream.cpp
$(CXX) -c -o $@ $(TEST_CXXFLAGS) $(CPPDEPS) $<
diff --git a/tests/makefile.vc b/tests/makefile.vc
index 9ccebcdd66..8ae6c6c439 100644
--- a/tests/makefile.vc
+++ b/tests/makefile.vc
@@ -97,6 +97,7 @@ TEST_OBJECTS = \
$(OBJS)\test_filestream.obj \
$(OBJS)\test_iostreams.obj \
$(OBJS)\test_largefile.obj \
+ $(OBJS)\test_lzmastream.obj \
$(OBJS)\test_memstream.obj \
$(OBJS)\test_socketstream.obj \
$(OBJS)\test_sstream.obj \
@@ -913,6 +914,9 @@ $(OBJS)\test_iostreams.obj: .\streams\iostreams.cpp
$(OBJS)\test_largefile.obj: .\streams\largefile.cpp
$(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) .\streams\largefile.cpp
+$(OBJS)\test_lzmastream.obj: .\streams\lzmastream.cpp
+ $(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) .\streams\lzmastream.cpp
+
$(OBJS)\test_memstream.obj: .\streams\memstream.cpp
$(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) .\streams\memstream.cpp
diff --git a/tests/streams/lzmastream.cpp b/tests/streams/lzmastream.cpp
new file mode 100644
index 0000000000..6bd6f2dd61
--- /dev/null
+++ b/tests/streams/lzmastream.cpp
@@ -0,0 +1,90 @@
+///////////////////////////////////////////////////////////////////////////////
+// Name: tests/streams/lzmastream.cpp
+// Purpose: Unit tests for LZMA stream classes
+// Author: Vadim Zeitlin
+// Created: 2018-03-30
+// Copyright: (c) 2018 Vadim Zeitlin
+// Licence: wxWindows licence
+///////////////////////////////////////////////////////////////////////////////
+
+#include "testprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+#if wxUSE_LIBLZMA && wxUSE_STREAMS
+
+#include "wx/mstream.h"
+#include "wx/lzmastream.h"
+
+#include "bstream.h"
+
+class LZMAStream : public BaseStreamTestCase
+{
+public:
+ LZMAStream();
+
+ CPPUNIT_TEST_SUITE(zlibStream);
+ // Base class stream tests.
+ CPPUNIT_TEST(Input_GetSizeFail);
+ CPPUNIT_TEST(Input_GetC);
+ CPPUNIT_TEST(Input_Read);
+ CPPUNIT_TEST(Input_Eof);
+ CPPUNIT_TEST(Input_LastRead);
+ CPPUNIT_TEST(Input_CanRead);
+ CPPUNIT_TEST(Input_SeekIFail);
+ CPPUNIT_TEST(Input_TellI);
+ CPPUNIT_TEST(Input_Peek);
+ CPPUNIT_TEST(Input_Ungetch);
+
+ CPPUNIT_TEST(Output_PutC);
+ CPPUNIT_TEST(Output_Write);
+ CPPUNIT_TEST(Output_LastWrite);
+ CPPUNIT_TEST(Output_SeekOFail);
+ CPPUNIT_TEST(Output_TellO);
+ CPPUNIT_TEST_SUITE_END();
+
+protected:
+ wxLZMAInputStream *DoCreateInStream() wxOVERRIDE;
+ wxLZMAOutputStream *DoCreateOutStream() wxOVERRIDE;
+
+private:
+ wxDECLARE_NO_COPY_CLASS(LZMAStream);
+};
+
+STREAM_TEST_SUBSUITE_NAMED_REGISTRATION(LZMAStream)
+
+LZMAStream::LZMAStream()
+{
+ // Disable TellI() and TellO() tests in the base class which don't work
+ // with the compressed streams.
+ m_bSimpleTellITest =
+ m_bSimpleTellOTest = true;
+}
+
+wxLZMAInputStream *LZMAStream::DoCreateInStream()
+{
+ // Compress some data.
+ const char data[] = "This is just some test data for LZMA streams unit test";
+ const size_t len = sizeof(data);
+
+ wxMemoryOutputStream outmem;
+ wxLZMAOutputStream outz(outmem);
+ outz.Write(data, len);
+ REQUIRE( outz.LastWrite() == len );
+ REQUIRE( outz.Close() );
+
+ wxMemoryInputStream* const inmem = new wxMemoryInputStream(outmem);
+ REQUIRE( inmem->IsOk() );
+
+ // Give ownership of the memory input stream to the LZMA stream.
+ return new wxLZMAInputStream(inmem);
+}
+
+wxLZMAOutputStream *LZMAStream::DoCreateOutStream()
+{
+ return new wxLZMAOutputStream(new wxMemoryOutputStream());
+}
+
+#endif // wxUSE_LIBLZMA && wxUSE_STREAMS
diff --git a/tests/test.bkl b/tests/test.bkl
index 95007b4836..47016bcf33 100644
--- a/tests/test.bkl
+++ b/tests/test.bkl
@@ -90,6 +90,7 @@
streams/filestream.cpp
streams/iostreams.cpp
streams/largefile.cpp
+ streams/lzmastream.cpp
streams/memstream.cpp
streams/socketstream.cpp
streams/sstream.cpp
diff --git a/tests/test.vcxproj b/tests/test.vcxproj
index 0844c93994..d4626936c7 100644
--- a/tests/test.vcxproj
+++ b/tests/test.vcxproj
@@ -517,6 +517,7 @@
+
@@ -553,4 +554,4 @@
-
+
\ No newline at end of file
diff --git a/tests/test.vcxproj.filters b/tests/test.vcxproj.filters
index d3365dc7e6..502e186b28 100644
--- a/tests/test.vcxproj.filters
+++ b/tests/test.vcxproj.filters
@@ -262,5 +262,8 @@
Source Files
+
+ Source Files
+
-
+
\ No newline at end of file
diff --git a/tests/test_vc7_test.vcproj b/tests/test_vc7_test.vcproj
index 45b3604544..9443e3b8c9 100644
--- a/tests/test_vc7_test.vcproj
+++ b/tests/test_vc7_test.vcproj
@@ -448,6 +448,9 @@
+
+
diff --git a/tests/test_vc8_test.vcproj b/tests/test_vc8_test.vcproj
index 6501c9dc08..d085fdc4a3 100644
--- a/tests/test_vc8_test.vcproj
+++ b/tests/test_vc8_test.vcproj
@@ -1066,6 +1066,10 @@
RelativePath=".\longlong\longlongtest.cpp"
>
+
+
diff --git a/tests/test_vc9_test.vcproj b/tests/test_vc9_test.vcproj
index 1c9cfd4b7c..4570595312 100644
--- a/tests/test_vc9_test.vcproj
+++ b/tests/test_vc9_test.vcproj
@@ -1038,6 +1038,10 @@
RelativePath=".\longlong\longlongtest.cpp"
>
+
+