TZCompressionStream使用问题。

cxxer 2022-04-05 20:35:16

 



 

 

 

 

 

void __fastcall TfrmMain::btnCompressClick(TObject *Sender)
{
	TFileStream *input = new TFileStream(Edit1->Text, fmOpenRead);
	TFileStream *output = new TFileStream(Edit2->Text + ".zip", fmCreate);
	TZCompressionStream *zip = new TZCompressionStream(output, zcDefault);

	zip->CopyFrom(input, input->Size);

	zip->Free();
	input->Free();
	output->Free();
}
//---------------------------------------------------------------------------
void __fastcall TfrmMain::btnDecompressClick(TObject *Sender)
{
	TFileStream *input = new TFileStream(Edit1->Text, fmOpenRead);
	TFileStream *output = new TFileStream(ChangeFileExt(Edit1->Text, ""), fmCreate);
	TZDecompressionStream *unzip = new TZDecompressionStream(input);

	output->CopyFrom(unzip, 0);

	unzip->Free();
	input->Free();
	output->Free();
}
//---------------------------------------------------------------------------
void __fastcall TfrmMain::Button1Click(TObject *Sender)
{
	if (OpenDialog1->Execute()) {
		Edit1->Text = OpenDialog1->FileName;
	}
}

[bcc32c Error] UnitZLibCompressDecompress.cpp(21): no matching constructor for initialization of 'System::Zlib::TZCompressionStream'
  System.ZLib.hpp(154): candidate constructor not viable: no known conversion from 'System::Classes::TFileStream *' to 'System::Zlib::TCompressionLevel' for 1st argument
  System.ZLib.hpp(152): candidate constructor not viable: requires single argument 'dest', but 2 arguments were provided
  System.ZLib.hpp(153): candidate constructor not viable: requires 3 arguments, but 2 were provided

...全文
126 3 打赏 收藏 举报
写回复
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
cxxer 04-06
```c++
class PASCALIMPLEMENTATION TZCompressionStream : public TCustomZStream
{
    typedef TCustomZStream inherited;
    
private:
    float __fastcall GetCompressionRate();
    
public:
    __fastcall TZCompressionStream(System::Classes::TStream* dest)/* overload */;
    __fastcall TZCompressionStream(System::Classes::TStream* dest, TZCompressionLevel compressionLevel, int windowBits)/* overload */;
    __fastcall TZCompressionStream(TCompressionLevel compressionLevel, System::Classes::TStream* dest)/* overload */;
    __fastcall virtual ~TZCompressionStream();
...
};
TZCompressionStream *zip = new TZCompressionStream(output,zcDefault,64);

```

  • 打赏
  • 举报
回复

TZCompressionStream的构造函数有1、2、3个参数三种重载,用两个参数的可以:
TZCompressionStream *zip = new TZCompressionStream(zcDefault, output);

  • 打赏
  • 举报
回复
ooolinux 04-05

构造函数参数不对。

  • 打赏
  • 举报
回复
相关推荐
发帖
C++ Builder
加入

1.3w+

社区成员

C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
申请成为版主
帖子事件
创建了帖子
2022-04-05 20:35
社区公告
暂无公告