C#43;#43;Builder6操作Zlib进行数据压缩
CHUNK, stderr); break; case Z_STREAM_ERROR: fputs(invalid compression level\n,因为是DLL的Zlib貌似不能直接在CB里修改这个利用txt文本打开修改保存再在Cb里运行 8、添加一个button空间输入代码最后出问题问题是 [Linker Error] Unresolved external _deflateInit_ referenced from E:\CBUILDER\SS\UNIT1.OBJ [Linker Error] Unresolved external _deflate referenced from E:\CBUILDER\SS\UNIT1.OBJ [Linker Error] Unresolved external _deflateEnd referenced from E:\CBUILDER\SS\UNIT1.OBJ 我不知道怎么修改了~~~郁闷, 1。
stderr); break; case Z_VERSION_ERROR: fputs(zlib version mismatch!\n, stderr); switch (ret) { case Z_ERRNO: if (ferror(stdin)) fputs(error reading stdin\n, int level) { int ret, Z_DEFAULT_COMPRESSION); // inf(); // int ret; // // /* do compression if no arguments */ // if (argc 1) { //ret def(stdin, MD5 checksum cc7fa97f9c19386bb701acc79d0abbca)” 2、解压缩得到文件夹及文件为include文件夹包括zconf.hzlib.h文件lib文件夹包括zdll.expzdll.libzlib.def文件test文件夹包括example_d.exeminigzip_exetestzlib_d.exeuntgz_d.exe文件以及四个文件DLL_FAQ.txtREADME.txtUSAGE.txt和zlib1.dll文件, 整个Unit1.cpp的源代码如下 //--------------------------------------------------------------------------- #include vcl.h #pragma hdrstop #include Unit1.h #include stdio.h #include string.h #include assert.h #include zlib.h #define CHUNK 16384 //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource *.dfm TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- /* Compress from file source to file dest until EOF on source. def() returns Z_OK on success, Z_DATA_ERROR if the deflate data is invalid or incomplete。
have, 6、利用Project-Add to Project将“..\Borland\CBuilder6\Lib\Zlib\zlib.lib”文件添加到当前工程中, Z_NO_FLUSH); assert(ret ! Z_STREAM_ERROR); /* state not clobbered */ switch (ret) { case Z_NEED_DICT: ret Z_DATA_ERROR;/* and fall through */ case Z_DATA_ERROR: case Z_MEM_ERROR: (void)inflateEnd(strm); return ret; } have CHUNK - strm.avail_out; if (fwrite(out, have。
zipfile format (79K。
3、利用CBuilder6的implib.exe将步骤2中的zlib1.dll转换为zlib.lib 4、将步骤2中的include文件夹中的zconf.hzlib.h文件放到CB的安装目录“..\CBuilder6\Include\”下自己建立了一个Zlib文件夹存放便于查找即最后的存放目录为“..\CBuilder6\Include\Zlib\zconf.h”以及“..\CBuilder6\Include\Zlib\zlib.h”, source); if (ferror(source)) { (void)inflateEnd(strm); return Z_ERRNO; } if (strm.avail_in 0) break; strm.next_in in; /* run inflate() on input until output buffer not full */ do { strm.avail_out CHUNK; strm.next_out out; ret inflate(strm, Z_STREAM_ERROR if an invalid compression level is supplied, or Z_ERRNO if there is an error reading or writing the files. */ int inf(FILE *source, , -d) 0) { //ret inf(stdin。
source); if (ferror(source)) { (void)deflateEnd(strm); return Z_ERRNO; } flush feof(source) ? Z_FINISH : Z_NO_FLUSH; strm.next_in in; /* run deflate() on input until output buffer not full, flush); /* no bad return value */ assert(ret ! Z_STREAM_ERROR); /* state not clobbered */ have CHUNK - strm.avail_out; if (fwrite(out, stdout); //if (ret ! Z_OK) //zerr(ret); //return ret; // } // // /* otherwise, Z_MEM_ERROR if memory could not be allocated for processing, stdout, Z_MEM_ERROR if memory could not be allocated for processing, 1, stderr); if (ferror(stdout)) fputs(error writing stdout\n。
将详细步骤贴在下面帖子较长给各位添麻烦了~~~不好意思 1、在网站中下载了Zlib.dll上面提供了四个我下载的是 “zlib compiled DLL, 1, stderr); break; case Z_DATA_ERROR: fputs(invalid or incomplete deflate data\n,同理将步骤3中生成的zlib.lib存放为“..\Borland\CBuilder6\Lib\Zlib\zlib.lib”下。
stderr); } } //----------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender) { def((FILE *)E:\\CBuilder\\ss\\zz.txt, Z_VERSION_ERROR if the version of zlib.h and the version of the library linked do not match。
report usage */ // else { //fputs(zpipe usage: zpipe [-d] source dest\n, Z_VERSION_ERROR if the version of zlib.h and the version of the library linked do not match, 5、新建CB工程, FILE *dest) { int ret; unsigned have; z_stream strm; char in[CHUNK]; char out[CHUNK]; /* allocate inflate state */ strm.zalloc Z_NULL; strm.zfree Z_NULL; strm.opaque Z_NULL; strm.avail_in 0; strm.next_in Z_NULL; ret inflateInit(strm); if (ret ! Z_OK) return ret; /* decompress until deflate stream ends or end of file */ do { strm.avail_in fread(in。
CHUNK, (FILE *)E:\\CBuilder\\ss\\out, stderr); //return 1; // } } //--------------------------------------------------------------------------- 这也是在Zlib网站上的源码里找的但是我不知道如何修改了请大家帮忙谢谢, finish compression if all of source has been read in */ do { strm.avail_out CHUNK; strm.next_out out; ret deflate(strm。
stderr); break; case Z_MEM_ERROR: fputs(out of memory\n。
1, or Z_ERRNO if there is an error reading or writing the files. */ int def(FILE *source, 7、在unit1.cpp里添加#include zlib.h编辑运行出错 E2015 Ambiguity between Byte and System::Byte 修改方式将该行的Byte改为System::Byte保存再编辑通过, 今天试了一下开源数据压缩Zlib在CBuilder6中的使用有些问题向大家请教一下,在Project-Options-Directories/Conditions中分别将“..\CBuilder6\Include\Zlib”添加到Include Path中以及将“..\Borland\CBuilder6\Lib\Zlib”添加到Library Path中, dest) ! have || ferror(dest)) { (void)inflateEnd(strm); return Z_ERRNO; } } while (strm.avail_out 0); /* done when inflate() says its done */ } while (ret ! Z_STREAM_END); /* clean up and return */ (void)inflateEnd(strm); return ret Z_STREAM_END ? Z_OK : Z_DATA_ERROR; } /* report a zlib or i/o error */ void zerr(int ret) { fputs(zpipe: 。
flush; unsigned have; z_stream strm; char in[CHUNK]; char out[CHUNK]; /* allocate deflate state */ strm.zalloc Z_NULL; strm.zfree Z_NULL; strm.opaque Z_NULL; ret deflateInit(strm,。
dest) ! have || ferror(dest)) { (void)deflateEnd(strm); return Z_ERRNO; } } while (strm.avail_out 0); assert(strm.avail_in 0);/* all input will be used */ /* done when last data in file processed */ } while (flush ! Z_FINISH); assert(ret Z_STREAM_END);/* stream will be complete */ /* clean up and return */ (void)deflateEnd(strm); return Z_OK; } //---------------------- /* Decompress from file source to file dest until stream ends or EOF. inf() returns Z_OK on success, version 1.2.3, Z_DEFAULT_COMPRESSION); //if (ret ! Z_OK) //zerr(ret); //return ret; // } // // /* do decompression if -d specified */ // else if (argc 2 strcmp(argv[1], level); if (ret ! Z_OK) return ret; /* compress until end of file */ do { strm.avail_in fread(in, FILE *dest, 帖子较长给各位添麻烦了~~~不好意思。
评论列表