这篇教程C++ zError函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中zError函数的典型用法代码示例。如果您正苦于以下问题:C++ zError函数的具体用法?C++ zError怎么用?C++ zError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了zError函数的26个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: GetDlgItemvoid CDlg_Compress::OnBnClickedBtnCompress(){ // 因为压缩函数的输出缓冲必须比输入大0.1% + 12 然后一个DWORD用来保存压缩前的大小 // int compress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen); CString strFileName; CString strCompress; GetDlgItem(IDC_COMPRESS_EDIT_FILENAME)->GetWindowText(strFileName); GetDlgItem(IDC_COMPRESS_EDIT_CONTENT)->GetWindowText(strCompress); int inLen = strCompress.GetLength(); unsigned char *out = new unsigned char[inLen*2]; unsigned long outLen = inLen*2; int ret = compress(out, &outLen, (LPBYTE)(LPCSTR)strCompress, inLen); if (0 == ret) { CFile File; if (File.Open(strFileName, CFile::modeCreate | CFile::modeReadWrite)) { File.Write(out, outLen); File.Close(); } MessageBox("Compress OK!"); } else { strCompress.Format("Error:%s", zError(ret)); MessageBox(strCompress); } delete[] out; }
开发者ID:tempbottle,项目名称:TestSet,代码行数:33,
示例2: deflateint DeflatingStreamBuf::readFromDevice(char* buffer, std::streamsize length){ if (!_pIstr) return 0; if (_zstr.avail_in == 0 && !_eof) { int n = 0; if (_pIstr->good()) { _pIstr->read(_buffer, DEFLATE_BUFFER_SIZE); n = static_cast<int>(_pIstr->gcount()); } if (n > 0) { _zstr.next_in = (unsigned char*) _buffer; _zstr.avail_in = n; } else { _zstr.next_in = 0; _zstr.avail_in = 0; _eof = true; } } _zstr.next_out = (unsigned char*) buffer; _zstr.avail_out = static_cast<unsigned>(length); for (;;) { int rc = deflate(&_zstr, _eof ? Z_FINISH : Z_NO_FLUSH); if (_eof && rc == Z_STREAM_END) { _pIstr = 0; return static_cast<int>(length) - _zstr.avail_out; } if (rc != Z_OK) throw IOException(zError(rc)); if (_zstr.avail_out == 0) { return static_cast<int>(length); } if (_zstr.avail_in == 0) { int n = 0; if (_pIstr->good()) { _pIstr->read(_buffer, DEFLATE_BUFFER_SIZE); n = static_cast<int>(_pIstr->gcount()); } if (n > 0) { _zstr.next_in = (unsigned char*) _buffer; _zstr.avail_in = n; } else { _zstr.next_in = 0; _zstr.avail_in = 0; _eof = true; } } }}
开发者ID:Adoni,项目名称:WiEngine,代码行数:60,
|