You are not logged in.
A little background:
I am working on 'NHunspell for Delphi' [ http://sourceforge.net/projects/nhunspelldelphi/ ] which uses PasZip v1.5.
As it is, it is a 32-bit code. In order to make it 64bit, other than using a 64bit Hunspell DLL, it needs PasZip that's 64bit compatible.
Now the problem:
When I replace PasZip v1.5 with v1.18 (the one available from GitHub MorMot), 'NHunspell for Delphi' compiles but it simply and silently fdoes not unzip anything --even for 32bit.
I couln't figure out what has changed between the versions (other than that the new one is 64bit compatible).
Could someone shed some light here --is there a compiler define I need to enable with the newer one, for example.
Offline
I forgot: I am using XE2.
Offline
I can't see why http://synopse.info/fossil/info/032fb0c … f9ef7e42d0 would have changed the unit behavior...
As far as I can tell, there was no code change in the last 5 years...
See the whole history at http://synopse.info/fossil/finfo?name=PasZip.pas
Offline
I have solved the mistery
In PasZip.pas:
NameToIndex() is declared as this:
function NameToIndex(const aName: AnsiString): integer;
but, is implemented as
function TZipRead.NameToIndex(const aName: string): integer;
Notice that 'AnsiString' has been replaced with 'string'.
It should, instead, be implemented as this:
function TZipRead.NameToIndex(const aName: AnsiString): integer;
---------------------
Another one is this:
function UnZip(aIndex: integer): string; overload;
It should return 'AnsiString' instead of 'string'
IOW, it should be corrected to be:
function UnZip(aIndex: integer): AnsiString; overload;
And, its implementation should be like this
function TZipRead.UnZip(aIndex: integer): AnsiString;
{snip}
begin
{snip}
MessageBoxA(0,'CRC',Name,0);
{snip}
end;
---------------------
And, a little nitpick:
in 'function InflateFast()', there's this code. In there 'inc(R, Extra)' is redundant because 3 lines down, 'R' is assigned a value. See below.
if C > Extra then begin
// copy to end of window
dec(C, Extra);
MoveWithOverlap(R, Q, Extra);
inc(R, Extra); { <--- REDUNDAT}
inc(Q, Extra);
// copy rest from start of window
R := S.window;
end;
---------------------
As you see, my focus has been on the unzipping side of things; I haven't looked ad zipping side of things at all.
But, having found the above AnsiString/string issues, I have become suspicious of routines such as 'function Zip()' as they seem to use 'string' a little too liberally.
But, I haven't checked them.
Offline
And, now, in order to compile PasZip under x64, the following changes need to be made in the code:
in UpdateCrc32()
inc(cardinal(inBuf));
should be:
inc(IntPtr(inBuf));
in CompressString()
i1 := {snip} PAnsiChar(integer(Result) + 12) {snip};
should be:
i1 := {snip} PAnsiChar(IntPtr(Result) + 12) {snip};
UncompressString()
SetLength( {snip} PAnsiChar(integer(data) {snip} );
should be:
SetLength( {snip} PAnsiChar(IntPtr(data) {snip} );
constructor TZipRead.Create();
inc(integer(H), {snip} );
should be:
inc(IntPtr(H), {snip} );
Offline
In fact, PasZip NEVER worked with Unicode versions of Delphi.
So I made a deep refactoring of the unit.
So that it now compiles and run under Win32 and Win64, with all supported Delphi and FPC compiler versions!
Offline
Thank you.
Just a reminder: It would be a good idea to change the version number --it still says 1.18
Another thing:
We don't need to pull in Synopse.inc just to define 'MSWINDOWS'.
The following is all we need instead of Synopse.inc
{$IFDEF WIN32}
{$DEFINE MSWINDOWS}
{$ELSE}
{$IFDEF WIN64}
{$DEFINE MSWINDOWS}
{$ELSE}
{$UNDEF MSWINDOWS}
{$ENDIF}
{$ENDIF}
Offline
Offline