#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
+#include <errno.h>
using namespace zipper;
#include <fcntl.h>
#include <unistd.h>
#include <utime.h>
+#include <errno.h>
using namespace zipper;
libzipper
Michael McMaster <michael@codesrc.com>
+* Refer to INSTALL.Android for Google Android NDK compilation information.
+
Pre-Requisites
g++ (4.5.3)
make (GNU make 3.81)
--- /dev/null
+libzipper
+Michael McMaster <michael@codesrc.com>
+
+Pre-Requisites
+ Android NDK (tested with android-ndk-r6)
+ Existing Android project
+
+NDK Limitations
+ * Your Application.mk file must enable C++ exceptions with:
+ APP_CPPFLAGS := -fexceptions -frtti
+ Although the NDK supports exceptions as of r5, they are disabled by
+ default for backwards compatibility.
+
+ * Your Application.mk file must specify a C++ STL implementation with
+ exception support. As of r6, only gnustl_static provides exception support.
+ APP_STL := gnustl_static
+
+Note that this port doesn't include any JNI interface code. It is expected that
+libzipper will be called from other native code libraries, and not directly
+from Java.
+
+Including libzipper in your NDK project:
+1) Modify your Application.mk file to include the module, and
+ set APP_CPPFLAGS and APP_STL as stated under "NDK Limitations" above.
+
+ APP_CPPFLAGS += -fexceptions -frtti
+ APP_STL := gnustl_static
+ APP_MODULES += zipper
+
+2) Modify your applications Android.mk file to import the libzipper module:
+
+ LOCAL_STATIC_LIBRARIES += libzipper
+ $(call import-module,zipper)
+
+3) Set the NDK_MODULE_PATH variable to include the libzipper source directory
+ when calling ndk-build.
+ eg. If libzipper was extracted to /tmp/libzipper-1.0.3:
+
+ cd /path/to/your/ndk/application
+ ndk-build NDK_MODULE_PATH="/tmp/libzipper-1.0.3/android"
include doxygen.am
-dist_noinst_SCRIPTS = autogen.sh
+dist_noinst_SCRIPTS = \
+ autogen.sh
+
+DIST_COMMON = \
+ config.guess \
+ config.sub \
+ depcomp \
+ install-sh \
+ ltmain.sh \
+ missing
+
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libzipper1.pc
EXTRA_DIST = \
COPYING \
INSTALL \
+ INSTALL.Android \
NEWS \
README \
- VERSION
+ VERSION \
+ android/zipper/Android.mk
lib_LTLIBRARIES = libzipper.la
gzip.hh \
Reader.cc \
split.hh \
- strerror.cc \
strerror.hh \
util.hh \
Writer.cc \
zip.hh \
zip.cc
+if HAVE_GNU_STRERROR
+libzipper_la_SOURCES += \
+ port/strerror_gnu.cc
+else
+libzipper_la_SOURCES += \
+ port/strerror_posix.cc
+endif
+
# Public API headers go here, for installation to /usr/include
include_HEADERS = zipper.hh
+2011-10-04 Version 1.0.3
+ - Added Android NDK support
+
2011-09-07 Version 1.0.2
- Fixed a bug in deflate, which caused it to exit prematurely and
report valid files as corrupt.
--- /dev/null
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_CFLAGS := -W -Wall -Werror -D_POSIX_C_SOURCE=200112
+
+LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../
+
+# bionic /sys/types.h fails with -std=c++0x, as it doesn't include
+# stdint.h, but tries to use uint64_t.
+LOCAL_CPPFLAGS := -std=gnu++0x
+LOCAL_EXPORT_CPPFLAGS := -std=gnu++0x
+
+# libzipper throws exceptions
+LOCAL_CPPFLAGS += -fexceptions -frtti
+LOCAL_EXPORT_CPPFLAGS += -fexceptions -frtti
+
+LOCAL_CPP_EXTENSION := .cc
+
+LOCAL_LDLIBS := -lz
+LOCAL_EXPORT_LDLIBS := -lz
+
+LOCAL_MODULE := zipper
+LOCAL_MODULE_FILENAME := libzipper
+
+LOCAL_SRC_FILES :=\
+ ../../CompressedFile.cc \
+ ../../deflate.cc \
+ ../../gzip.cc \
+ ../../zip.cc \
+ ../../Compressor.cc \
+ ../../Exception.cc \
+ ../../Reader.cc \
+ ../../zipper.cc \
+ ../../Container.cc \
+ ../../FileReader.cc \
+ ../../Decompressor.cc \
+ ../../FileWriter.cc \
+ ../../Writer.cc \
+ ../../port/strerror_posix.cc \
+
+include $(BUILD_STATIC_LIBRARY)
cd libzipper-${VERSION}
dpkg-buildpackage -rfakeroot
-if ! lintian --color auto --fail-on-warnings -i ${BUILD}/libzipper_1.0.2-1.dsc; then
+if ! lintian --color auto --fail-on-warnings -i ${BUILD}/libzipper_1.0.3-1.dsc; then
echo "Build failed"
exit 1;
-elif ! lintian --color auto --fail-on-warnings -i ${BUILD}/libzipper_1.0.2-1_amd64.changes; then
+elif ! lintian --color auto --fail-on-warnings -i ${BUILD}/libzipper_1.0.3-1_amd64.changes; then
echo "Build failed"
exit 1;
else
AC_SUBST([libzipper_version], m4_esyscmd_s([cat VERSION]))
AC_PROG_CXX
-AC_PROG_LIBTOOL
+AC_LANG([C++])
+AM_PROG_LIBTOOL
+
+AC_FUNC_STRERROR_R
+AM_CONDITIONAL(HAVE_GNU_STRERROR,[test x$ac_cv_func_strerror_r_char_p = xyes])
DX_DOXYGEN_FEATURE([ON])
DX_HTML_FEATURE([ON])
+libzipper (1.0.3-1) unstable; urgency=low
+
+ * Added Android NDK support
+
+ -- Michael McMaster <michael@codesrc.com> Tue, 04 Oct 2011 13:22:11 +1000
+
libzipper (1.0.2-1) unstable; urgency=low
* Fixed a bug in the deflate methods, which would report corrupt data for
--- /dev/null
+// Copyright (C) 2011 Michael McMaster <michael@codesrc.com>
+//
+// This file is part of libzipper.
+//
+// libzipper is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// libzipper is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with libzipper. If not, see <http://www.gnu.org/licenses/>.
+
+#define _GNU_SOURCE
+
+#include "../strerror.hh"
+
+#include <string.h>
+
+using namespace zipper;
+
+std::string
+zipper::strerror(int errnum)
+{
+ char buf[1024];
+ const char* message(NULL);
+
+ // The GNU-specific strerror_r may use the provided buffer, OR a static
+ // buffer.
+ message = strerror_r(errnum, buf, sizeof(buf));
+
+ return std::string(message);
+}
+
// You should have received a copy of the GNU General Public License
// along with libzipper. If not, see <http://www.gnu.org/licenses/>.
-#include "strerror.hh"
+#include "../strerror.hh"
#include <string.h>
zipper::strerror(int errnum)
{
char buf[1024];
- char* message(NULL);
+ const char* message(NULL);
-#ifdef _GNU_SOURCE
- // The GNU-specific strerror_r may use the provided buffer, OR a static
- // buffer.
- message = strerror_r(errnum, buf, sizeof(buf));
-
-#elif (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600)
+#if (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600)
int error(strerror_r(errnum, buf, sizeof(buf)));
if (error != 0)
{
message = "Unknown error";
}
-
#else
// Thread-unsafe fallback
- message = strerror(errnum);
+ message = ::strerror(errnum);
#endif
return std::string(message);
centralDirectoryEntries
)
);
+ (void) isZip; // Avoid unused warning.
assert(isZip);
std::vector<uint8_t> buffer(centralDirectoryBytes);
#include "zipper.hh"
#include "split.hh"
+#include <errno.h>
#include "strerror.hh"
#include <cassert>