编辑为什么我在使用zlib deflate的源文件中获得一个恐怖?
// open output file for writing
if ((outfilefd = fopen(file_name, "w+t")) == NULL)
{
fprintf(stderr, "Unable to create file\n");
exit(1);
}
写入文件,那么就需要压缩它。
打开.Z文件,然后调用DEF()
FILE *zipFile;
if ((zipFile = fopen("C:\\LOGS\\test.txt.z", "w+t")) == NULL)
{
fprintf(stderr, "Unable to create file\n");
exit(1);
}
int ret = def(outfilefd, zipFile, Z_DEFAULT_COMPRESSION);
if (ret != Z_OK)
printf("ZLIB Error");
使用DEF(),从一site:
int def(FILE *source, FILE *dest, int level)
{
int ret, flush;
unsigned have;
z_stream strm;
unsigned char in[CHUNK];
unsigned char out[CHUNK];
/* allocate deflate state */
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
ret = deflateInit(&strm, level);
if (ret != Z_OK)
return ret;
/* compress until end of file */
do {
strm.avail_in = fread(in, 1, CHUNK, source);
int g = ferror(source);//<---------------- EROR HERE returning 32?
if (ferror(source)) {
(void)deflateEnd(&strm);
return Z_ERRNO;
}
zipFile
不为空,strm.avail_in
= 16343,in
已数据但ferror(source)
返回32?
编辑 - 也strm.avail_in
= 16343引起了我的CHUNK
= 16384眼....行吗?
任何想法或帮助表示赞赏。
谢谢。
我不知道是什么32。尝试[perror](http://www.opengroup.org/onlinepubs/000095399/functions/perror.html)以打印错误文本。 – 2010-07-16 01:03:23
在您的平台上errno 32的含义是什么,您可能会误解(“”)吗?在Linux上它说破管,这听起来很奇怪,因为你打开一个文件。 – mvds 2010-07-16 01:05:18
也许只是展示你如何打开源代码,这是你的问题,为什么我们应该假设或猜测? – mvds 2010-07-16 01:06:16