views:

151

answers:

4

Hi.

I have download and install KaZip2.0 on C++Builder2009 (with little minor changes => only set type String to AnsiString). I have write:

KAZip1->FileName = "test.zip";
KAZip1->CreateZip("test.zip");
KAZip1->Active = true;
KAZip1->Entries->AddFile("pack\\text.txt","xxx.txt");
KAZip1->Active = false;
KAZip1->Close();

now he create a test.zip with included xxx.txt (59byte original, 21byte packed). I open the archiv in WinRAR successful and want open the xxx.txt, but WinRAR says file is corrupt. :(

What is wrong? Can somebody help me?

Extract not working, because file is corrupt?

KAZip1->FileName = "test.zip";
KAZip1->Active = true;
KAZip1->Entries->ExtractToFile("xxx.txt","zzz.txt");
KAZip1->Active = false;
KAZip1->Close();
A: 

WinRAR could be simply failing to recognize the header. Try opening it in Windows or some other zip programs.

DeadMG
With Windows I can open the Zip too, but not show in xxx.txt
Katsumi
A: 

with little minor changes => only set type String to AnsiString

That's doesn't work always right, it may compile but it doesn't mean it will work right in D2009 or CB2009, you need to show the places that you convert Strings to AnsiStrings, specially the code deal with : Buffers, Streams and I/O.

Mohammed Nasman
+1  A: 

with little minor changes => only set type String to AnsiString

Use RawByteString instead of AnsiString.

vcldeveloper
+1  A: 

I have no idea how KaZip2.0 is implemented, but in general, to make a Delphi/C++ library that was designed without Unicode support in mind working properly you need to do two things:

  • Replace all Char with AnsiChar and all string to AnsiString
  • Replace all Win API calls with their Ansi variant, i.e. replace AWin32Function with AWin32FunctionA.

In Delphi < 2009, Char = AnsiChar, String = AnsiString, AWin32Function = AWin32FunctionA, but in Delphi >= 2009, by default, Char = WideChar, String = UnicodeString, AWin32Function = AWin32FunctionW.

Andreas Rejbrand