mORMot and Open Source friends
Check-in [032fb0c788]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:{1914} enhanced PasZip support for Win64
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 032fb0c788e1a3a02efdd95b9add09f9ef7e42d0
User & Date: ab 2015-09-24 11:17:22
Context
2015-09-24
11:19
{1915} fixed "Grid Out of Range" issue in DDD's ToolsAdmin check-in: 555112f1fd user: ab tags: trunk
11:17
{1914} enhanced PasZip support for Win64 check-in: 032fb0c788 user: ab tags: trunk
11:16
{1913} low-level WebSockets frames would log the binary values as hexadecimal check-in: 1205f7935a user: ab tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to PasZip.pas.

38
39
40
41
42
43
44


45
46
47
48
49
50
51
52
53
54
55
..
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
...
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
....
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
....
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
....
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
}

{$WARNINGS OFF}
{$Q-,R-}  // Turn range checking and overflow checking off

{ $D-,L-}



interface

uses
{$ifdef WIN32}
  Windows,
{$else}
  LibC, Types,
{$endif}
  SysUtils;

/// compress memory using the ZLib DEFLATE algorithm
................................................................................
/// compress memory using the ZLib DEFLATE algorithm
function CompressString(const data: string; failIfGrow: boolean = false) : string;

/// uncompress memory using the ZLib INFLATE algorithm
function UncompressString(const data: string) : string;


{$ifdef WIN32} { use Windows MapFile }
function CompressFile(const srcFile, dstFile: string; failIfGrow: boolean = false) : boolean;
function UncompressFile(const srcFile, dstFile: string; lastWriteTime: int64 = 0; attr: dword = 0) : boolean;

function GetCompressedFileInfo   (const comprFile: string; var size: int64; var crc32: dword) : boolean;
function GetUncompressedFileInfo (const uncomprFile: string; var size: int64; var crc32: dword) : boolean;
function IsCompressedFileEqual   (const uncomprFile, comprFile: string) : boolean;

................................................................................
    thisFiles     : word;            // 1
    totalFiles    : word;            // 1
    headerSize    : dword;           // sizeOf(TFileHeaders + names)
    headerOffset  : dword;           // @TFileHeader
    commentLen    : word;            // 0
  end;

{$ifdef WIN32}
type
  /// stores an entry of a file inside a .zip archive
  TZipEntry = packed record
     /// the information of this file, as stored in the .zip archive
     info: PFileInfo;
     /// points to the compressed data in the .zip archive, mapped in memory
     data: PAnsiChar;
     /// ASCIIZ name of the file inside the .zip archive
     // - not a string, but a fixed-length array of char
     Name: array[0..127-8] of AnsiChar;
  end;

  /// read-only access to a .zip archive file
  // - can open directly a specified .zip file (will be memory mapped for fast access)
  // - can open a .zip archive file content from a resource (embedded in the executable)
  // - can open a .zip archive file content from memory
  TZipRead = class
................................................................................
    if (result <> '') and ((not updateCrc32($FFFFFFFF, pointer(result), length(result))) <> TPACardinal(data)^[2]) then
      result := '';
  end else
    result := '';
end;


{$ifdef WIN32}
type splitInt64 = record loCard, hiCard : cardinal end;

function CompressFile(const srcFile, dstFile: string; failIfGrow: boolean = false) : boolean;
var sf, df : dword;
    sm, dm : dword;
    sb, db : pointer;
    sl, dl : int64;
................................................................................
    close(f);
  end;
  {$I+} if ioresult<>0 then exit;
  result := destLen+18;
end;


{$ifdef WIN32}
function Zip(const zip: string; const files, zipAs: array of string; NoSubDirectories: boolean=false) : boolean;
var i1, i2, i3 : integer;
    dstFh      : dword;
    srcFh      : dword;
    ft         : TFileTime;
    c1         : dword;
    lfhr       : TLocalFileHeader;
................................................................................
        crc := (crc shr 1) xor $edb88320 else
        crc := crc shr 1;
    CRC32Tab[i] := crc;
  end;
end;
{$endif}

{$ifdef Win32}

{ TZipRead }

constructor TZipRead.Create(BufZip: pByteArray; Size: cardinal);
var lhr: ^TLastHeader;
    h: ^TFileHeader;
    lfhr: ^TLocalFileHeader;






>
>



|







 







|







 







|



|
|
|
|
|
|
|







 







|







 







|







 







|







38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
..
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
...
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
....
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
....
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
....
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
}

{$WARNINGS OFF}
{$Q-,R-}  // Turn range checking and overflow checking off

{ $D-,L-}

{$I Synopse.inc}

interface

uses
{$ifdef MSWINDOWS}
  Windows,
{$else}
  LibC, Types,
{$endif}
  SysUtils;

/// compress memory using the ZLib DEFLATE algorithm
................................................................................
/// compress memory using the ZLib DEFLATE algorithm
function CompressString(const data: string; failIfGrow: boolean = false) : string;

/// uncompress memory using the ZLib INFLATE algorithm
function UncompressString(const data: string) : string;


{$ifdef MSWINDOWS} { use Windows MapFile }
function CompressFile(const srcFile, dstFile: string; failIfGrow: boolean = false) : boolean;
function UncompressFile(const srcFile, dstFile: string; lastWriteTime: int64 = 0; attr: dword = 0) : boolean;

function GetCompressedFileInfo   (const comprFile: string; var size: int64; var crc32: dword) : boolean;
function GetUncompressedFileInfo (const uncomprFile: string; var size: int64; var crc32: dword) : boolean;
function IsCompressedFileEqual   (const uncomprFile, comprFile: string) : boolean;

................................................................................
    thisFiles     : word;            // 1
    totalFiles    : word;            // 1
    headerSize    : dword;           // sizeOf(TFileHeaders + names)
    headerOffset  : dword;           // @TFileHeader
    commentLen    : word;            // 0
  end;

{$ifdef MSWINDOWS}
type
  /// stores an entry of a file inside a .zip archive
  TZipEntry = packed record
    /// the information of this file, as stored in the .zip archive
    info: PFileInfo;
    /// points to the compressed data in the .zip archive, mapped in memory
    data: PAnsiChar;
    /// ASCIIZ name of the file inside the .zip archive
    // - not a string, but a fixed-length array of char
    Name: array[0..127-8] of AnsiChar;
  end;

  /// read-only access to a .zip archive file
  // - can open directly a specified .zip file (will be memory mapped for fast access)
  // - can open a .zip archive file content from a resource (embedded in the executable)
  // - can open a .zip archive file content from memory
  TZipRead = class
................................................................................
    if (result <> '') and ((not updateCrc32($FFFFFFFF, pointer(result), length(result))) <> TPACardinal(data)^[2]) then
      result := '';
  end else
    result := '';
end;


{$ifdef MSWINDOWS}
type splitInt64 = record loCard, hiCard : cardinal end;

function CompressFile(const srcFile, dstFile: string; failIfGrow: boolean = false) : boolean;
var sf, df : dword;
    sm, dm : dword;
    sb, db : pointer;
    sl, dl : int64;
................................................................................
    close(f);
  end;
  {$I+} if ioresult<>0 then exit;
  result := destLen+18;
end;


{$ifdef MSWINDOWS}
function Zip(const zip: string; const files, zipAs: array of string; NoSubDirectories: boolean=false) : boolean;
var i1, i2, i3 : integer;
    dstFh      : dword;
    srcFh      : dword;
    ft         : TFileTime;
    c1         : dword;
    lfhr       : TLocalFileHeader;
................................................................................
        crc := (crc shr 1) xor $edb88320 else
        crc := crc shr 1;
    CRC32Tab[i] := crc;
  end;
end;
{$endif}

{$ifdef MSWINDOWS}

{ TZipRead }

constructor TZipRead.Create(BufZip: pByteArray; Size: cardinal);
var lhr: ^TLastHeader;
    h: ^TFileHeader;
    lfhr: ^TLocalFileHeader;

Changes to SynopseCommit.inc.

1
'1.18.1913'
|
1
'1.18.1914'