[PATCH 1/1] Fix compilation with libzip < 0.10
Thiago Macieira
thiago at macieira.org
Thu Dec 19 17:01:54 UTC 2013
Signed-off-by: Thiago Macieira <thiago at macieira.org>
---
qt-ui/subsurfacewebservices.cpp | 2 +-
windows.c | 7 ++++++-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/qt-ui/subsurfacewebservices.cpp b/qt-ui/subsurfacewebservices.cpp
index af0e404..2a2d2b3 100644
--- a/qt-ui/subsurfacewebservices.cpp
+++ b/qt-ui/subsurfacewebservices.cpp
@@ -758,7 +758,7 @@ void DivelogsDeWebServices::downloadFinished()
int errorcode;
zipFile.seek(0);
-#ifdef Q_OS_UNIX
+#if defined(Q_OS_UNIX) && defined(LIBZIP_VERSION_MAJOR)
int duppedfd = dup(zipFile.handle());
struct zip *zip = zip_fdopen(duppedfd, 0, &errorcode);
if (!zip)
diff --git a/windows.c b/windows.c
index 536205c..9288af4 100644
--- a/windows.c
+++ b/windows.c
@@ -157,14 +157,19 @@ void *subsurface_opendir(const char *path)
#define O_BINARY 0
#endif
-/* we use zip_fdopen since zip_open doesn't have a wchar_t version */
struct zip *subsurface_zip_open_readonly(const char *path, int flags, int *errorp)
{
+#if defined(LIBZIP_VERSION_MAJOR)
+ /* libzip 0.10 has zip_fdopen, let's use it since zip_open doesn't have a
+ * wchar_t version */
int fd = subsurface_open(path, O_RDONLY | O_BINARY, 0);
struct zip *ret = zip_fdopen(fd, flags, errorp);
if (!ret)
close(fd);
return ret;
+#else
+ return zip_open(path, flags, errorp);
+#endif
}
int subsurface_zip_close(struct zip *zip)
--
1.7.11.7
More information about the subsurface
mailing list