mirror of https://github.com/BOINC/boinc.git
parent
8bb3e3cfb1
commit
d982308ec1
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\lib,..\,.\"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
|
||||
AdditionalIncludeDirectories="..\lib,..\,.\,..\..\zlib"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;USE_ZLIB"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
PrecompiledHeaderFile=".\Debug/boinc_zip.pch"
|
||||
|
@ -73,8 +73,8 @@
|
|||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
AdditionalIncludeDirectories="..\lib,..\,.\"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
|
||||
AdditionalIncludeDirectories="..\lib,..\,.\,..\..\zlib"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;USE_ZLIB"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
|
|
|
@ -2,26 +2,65 @@
|
|||
//
|
||||
|
||||
#ifndef _WIN32
|
||||
#include "../boinc/config.h"
|
||||
#include "../config.h"
|
||||
#endif
|
||||
#include "boinc_zip.h"
|
||||
#include "filesys.h"
|
||||
#include <zlib.h> // 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;
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@
|
|||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../boinc/zip,.."
|
||||
AdditionalIncludeDirectories="..,../../zlib,../lib"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
|
@ -92,16 +92,17 @@
|
|||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"
|
||||
DebugInformationFormat="4"
|
||||
CompileAs="2"/>
|
||||
CompileAs="2"
|
||||
ForcedIncludeFiles="windows.h"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="boinc_zipd.lib"
|
||||
AdditionalDependencies="boinc_zipd.lib zlibd.lib libboincd.lib"
|
||||
OutputFile="ziptest.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
AdditionalLibraryDirectories="../boinc/zip"
|
||||
AdditionalLibraryDirectories="../boinc/zip;../../monitor/lib"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile=".\Debug/ziptest.pdb"
|
||||
SubSystem="1"
|
||||
|
@ -138,46 +139,6 @@
|
|||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat;f90;for;f;fpp">
|
||||
<File
|
||||
RelativePath="..\boinc\lib\filesys.C">
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions=""/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"
|
||||
CompileAs="2"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\boinc\lib\util.C">
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions=""/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"
|
||||
CompileAs="2"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="ziptest.cpp">
|
||||
<FileConfiguration
|
||||
|
|
Loading…
Reference in New Issue