From d982308ec100fb039a7a8aef663a5063d9b6cfce Mon Sep 17 00:00:00 2001 From: David Anderson Date: Mon, 15 Aug 2005 18:05:21 +0000 Subject: [PATCH] zip build fix svn path=/trunk/boinc/; revision=7334 --- checkin_notes | 18 ++++++++++++++ zip/Makefile.am | 2 +- zip/README.txt | 3 +++ zip/boinc_zip.vcproj | 8 +++---- zip/ziptest.cpp | 57 +++++++++++++++++++++++++++++++++++++------- zip/ziptest.vcproj | 49 ++++--------------------------------- 6 files changed, 79 insertions(+), 58 deletions(-) diff --git a/checkin_notes b/checkin_notes index bf45e9b976..d3d31e88ed 100755 --- a/checkin_notes +++ b/checkin_notes @@ -10596,3 +10596,21 @@ Rom 15 Aug 2005 WizAttachProject.cpp, .h lib/ gui_rpc_client_ops.C + +David 15 Aug 2005 + - Happily, I found a more elegant solution than renaming functions & variables + from boinc_zip to zlib. + The InfoZip has a define "USE_ZLIB" which will take into account + that you have zlib available. + Since that is the de-facto boinc + (i.e. we're all using zlib now) + then boinc_zip can reflect this; + and I have updated the necessary files. + (from Carl Christensen) + + zip/ + Makefile.am + README.txt + boinc_zip.vcproj + ziptest.cpp + ziptest.vcproj diff --git a/zip/Makefile.am b/zip/Makefile.am index 2f62508902..e0657d9d8d 100644 --- a/zip/Makefile.am +++ b/zip/Makefile.am @@ -4,7 +4,7 @@ SUBDIRS = zip unzip -AM_CPPFLAGS = -I$(top_srcdir)/lib -I$(top_srcdir)/zip -I$(top_srcdir)/zip/zip -I$(top_srcdir)/zip/unzip -DUNIX +AM_CPPFLAGS = -I$(top_srcdir)/zlib -I$(top_srcdir)/lib -I$(top_srcdir)/zip -I$(top_srcdir)/zip/zip -I$(top_srcdir)/zip/unzip -DUNIX -DUSE_ZLIB ##noinst_PROGRAMS = test lib_LIBRARIES = libboinc_zip.a diff --git a/zip/README.txt b/zip/README.txt index 90479152b1..1a6d8a60f8 100644 --- a/zip/README.txt +++ b/zip/README.txt @@ -87,3 +87,6 @@ There is a "ziptest" Project for Windows provided to experiment, which can also be run (the "ziptest.cpp") on Unix & Mac to experiment with how boinc_zip work (just g++ with the boinc/lib/filesys.C & util.C as described above). + +NB -- this library can now "co-exist" with zlib (libz) as of 15/08/2005 +using the USE_ZLIB define in the VC project & Makefile.am diff --git a/zip/boinc_zip.vcproj b/zip/boinc_zip.vcproj index a2de8c1fde..446898a036 100644 --- a/zip/boinc_zip.vcproj +++ b/zip/boinc_zip.vcproj @@ -22,8 +22,8 @@ // CMC -- test that we "co-exist" with the "stock" zlib library + +int do_gzip(const char* strGZ, const char* strInput) +{ + // take an input file (strInput) and turn it into a compressed file (strGZ) + // get rid of the input file after + + FILE* fIn = boinc_fopen(strInput, "rb"); + if (!fIn) return 1; //error + gzFile fOut = gzopen(strGZ, "wb"); + if (!fOut) return 1; //error + + fseek(fIn, 0, SEEK_SET); // go to the top of the files + gzseek(fOut, 0, SEEK_SET); + unsigned char buf[1024]; + long lRead = 0, lWrite = 0; + while (!feof(fIn)) { // read 1KB at a time until end of file + memset(buf, 0x00, 1024); + lRead = 0; + lRead = fread(buf, 1, 1024, fIn); + lWrite = gzwrite(fOut, buf, lRead); + if (lRead != lWrite) break; + } + gzclose(fOut); + fclose(fIn); + + if (lRead != lWrite) return 1; //error -- read bytes != written bytes + + // if we made it here, it compressed OK, can erase strInput and leave + boinc_delete_file(strInput); + return 0; +} int main(int argc, char* argv[]) { ZipFileList zflist; #ifdef _WIN32 - boinc_filelist("temp/linux", "", &zflist, SORT_NAME | SORT_ASCENDING); + boinc_filelist("c:\\temp", "", &zflist, SORT_NAME | SORT_ASCENDING); #else - boinc_filelist("/var/home/carlc", "", &zflist, SORT_NAME | SORT_ASCENDING); + boinc_filelist("/tmp/junk", "", &zflist, SORT_NAME | SORT_ASCENDING); #endif - int jj; - for (jj = 0; jj < zflist.size(); jj++) - printf("%s %d\n", zflist[jj].c_str(), zflist[jj].m_statFile.st_mtime); - + int jj; + char strTmp[128]; + for (jj = 0; jj < zflist.size(); jj++) { + printf("%s %d\n", zflist[jj].c_str(), zflist[jj].m_statFile.st_mtime); + // now gzip it, silly but see how it goes! + sprintf(strTmp, "%s.gz", zflist[jj].c_str()); + do_gzip(strTmp, zflist[jj].c_str()); + } #ifdef _WIN32 - boinc_zip(ZIP_IT, "c:\\temp\\bztest", &zflist); + boinc_filelist("c:\\temp", "", &zflist, SORT_NAME | SORT_ASCENDING); + boinc_zip(ZIP_IT, "c:\\temp\\newzip", &zflist); #else - boinc_zip(ZIP_IT, "./ziptest.zip", &zflist); + boinc_filelist("/tmp/junk/", "", &zflist, SORT_NAME | SORT_ASCENDING); + boinc_zip(ZIP_IT, "./ziptest.zip", &zflist); #endif return 0; } diff --git a/zip/ziptest.vcproj b/zip/ziptest.vcproj index d5f495fe90..af334f5620 100644 --- a/zip/ziptest.vcproj +++ b/zip/ziptest.vcproj @@ -81,7 +81,7 @@ + CompileAs="2" + ForcedIncludeFiles="windows.h"/> - - - - - - - - - - - - - - - -