summaryrefslogtreecommitdiffstats
path: root/Source/cmSystemTools.cxx
diff options
context:
space:
mode:
authorAndy Cedilnik <andy.cedilnik@kitware.com>2005-12-30 19:22:46 (GMT)
committerAndy Cedilnik <andy.cedilnik@kitware.com>2005-12-30 19:22:46 (GMT)
commit6d0f0e0acb95c23a476510726bf7c5fe6fb840bf (patch)
tree0bf1ae222c7564868e7115f5fa5285dec947c908 /Source/cmSystemTools.cxx
parent01ac4158ed47f82b0d7ee7015d1cc38943d86eee (diff)
downloadCMake-6d0f0e0acb95c23a476510726bf7c5fe6fb840bf.zip
CMake-6d0f0e0acb95c23a476510726bf7c5fe6fb840bf.tar.gz
CMake-6d0f0e0acb95c23a476510726bf7c5fe6fb840bf.tar.bz2
COMP: Fix support for gzip on non-32 bit platforms
Diffstat (limited to 'Source/cmSystemTools.cxx')
-rw-r--r--Source/cmSystemTools.cxx74
1 files changed, 60 insertions, 14 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index f7ea1ef..7caafd0 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -1365,12 +1365,22 @@ bool cmSystemTools::IsPathToFramework(const char* path)
# include <fcntl.h>
# include <cmzlib/zlib.h>
-static int gzopen_frontend(char *pathname, int oflags, int mode)
+struct cmSystemToolsGZStruct
+{
+ gzFile GZFile;
+ static int Open(void* call_data, const char *pathname, int oflags, mode_t mode);
+ static int Close(void* call_data, int fd);
+ static ssize_t Read(void* call_data, int fd, void* buf, size_t count);
+ static ssize_t Write(void* call_data, int fd, const void* buf, size_t count);
+};
+
+int cmSystemToolsGZStruct::Open(void* call_data, const char *pathname, int oflags, mode_t mode)
{
char *gzoflags;
- gzFile gzf;
int fd;
+ cmSystemToolsGZStruct* gzf = static_cast<cmSystemToolsGZStruct*>(call_data);
+
switch (oflags & O_ACCMODE)
{
case O_WRONLY:
@@ -1398,14 +1408,35 @@ static int gzopen_frontend(char *pathname, int oflags, int mode)
}
#endif
- gzf = cm_zlib_gzdopen(fd, gzoflags);
- if (!gzf)
+ gzf->GZFile = cm_zlib_gzdopen(fd, gzoflags);
+ if (!gzf->GZFile)
{
errno = ENOMEM;
return -1;
}
- return (int)gzf;
+ return fd;
+}
+
+int cmSystemToolsGZStruct::Close(void* call_data, int fd)
+{
+ (void)fd;
+ cmSystemToolsGZStruct* gzf = static_cast<cmSystemToolsGZStruct*>(call_data);
+ return cm_zlib_gzclose(gzf->GZFile);
+}
+
+ssize_t cmSystemToolsGZStruct::Read(void* call_data, int fd, void* buf, size_t count)
+{
+ (void)fd;
+ cmSystemToolsGZStruct* gzf = static_cast<cmSystemToolsGZStruct*>(call_data);
+ return cm_zlib_gzread(gzf->GZFile, buf, count);
+}
+
+ssize_t cmSystemToolsGZStruct::Write(void* call_data, int fd, const void* buf, size_t count)
+{
+ (void)fd;
+ cmSystemToolsGZStruct* gzf = static_cast<cmSystemToolsGZStruct*>(call_data);
+ return cm_zlib_gzwrite(gzf->GZFile, (void*)buf, count);
}
#endif
@@ -1416,9 +1447,14 @@ bool cmSystemTools::CreateTar(const char* outFileName, const std::vector<cmStdSt
TAR *t;
char buf[TAR_MAXPATHLEN];
char pathname[TAR_MAXPATHLEN];
-
- tartype_t gztype = { (openfunc_t) gzopen_frontend, (closefunc_t) cm_zlib_gzclose,
- (readfunc_t) cm_zlib_gzread, (writefunc_t) cm_zlib_gzwrite
+ cmSystemToolsGZStruct gzs;
+
+ tartype_t gztype = {
+ cmSystemToolsGZStruct::Open,
+ cmSystemToolsGZStruct::Close,
+ cmSystemToolsGZStruct::Read,
+ cmSystemToolsGZStruct::Write,
+ &gzs
};
// Ok, this libtar is not const safe. for now use auto_ptr hack
@@ -1476,9 +1512,14 @@ bool cmSystemTools::ExtractTar(const char* outFileName, const std::vector<cmStdS
(void)files;
#if defined(CMAKE_BUILD_WITH_CMAKE)
TAR *t;
-
- tartype_t gztype = { (openfunc_t) gzopen_frontend, (closefunc_t) cm_zlib_gzclose,
- (readfunc_t) cm_zlib_gzread, (writefunc_t) cm_zlib_gzwrite
+ cmSystemToolsGZStruct gzs;
+
+ tartype_t gztype = {
+ cmSystemToolsGZStruct::Open,
+ cmSystemToolsGZStruct::Close,
+ cmSystemToolsGZStruct::Read,
+ cmSystemToolsGZStruct::Write,
+ &gzs
};
// Ok, this libtar is not const safe. for now use auto_ptr hack
@@ -1520,9 +1561,14 @@ bool cmSystemTools::ListTar(const char* outFileName, std::vector<cmStdString>& f
{
#if defined(CMAKE_BUILD_WITH_CMAKE)
TAR *t;
-
- tartype_t gztype = { (openfunc_t) gzopen_frontend, (closefunc_t) cm_zlib_gzclose,
- (readfunc_t) cm_zlib_gzread, (writefunc_t) cm_zlib_gzwrite
+ cmSystemToolsGZStruct gzs;
+
+ tartype_t gztype = {
+ cmSystemToolsGZStruct::Open,
+ cmSystemToolsGZStruct::Close,
+ cmSystemToolsGZStruct::Read,
+ cmSystemToolsGZStruct::Write,
+ &gzs
};
// Ok, this libtar is not const safe. for now use auto_ptr hack