Skip to content

Commit

Permalink
Zip64 fixes for ZipOutputStream. UseZip64 property now public in ZipO…
Browse files Browse the repository at this point in the history
…utputStream.cs Tests updated.
  • Loading branch information
jfreilly committed Jun 22, 2007
1 parent 886d477 commit 090fee6
Show file tree
Hide file tree
Showing 12 changed files with 200 additions and 337 deletions.
2 changes: 1 addition & 1 deletion samples/cs/CreateZipFile/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

[assembly: AssemblyVersion("0.85.2.324")]
[assembly: AssemblyVersion("0.85.2.329")]

[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile("")]
Expand Down
2 changes: 1 addition & 1 deletion samples/cs/FastZip/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
// You can specify all values by your own or you can build default build and revision
// numbers with the '*' character (the default):

[assembly: AssemblyVersion("0.85.2.324")]
[assembly: AssemblyVersion("0.85.2.329")]

// The following attributes specify the key for the sign of your assembly. See the
// .NET Framework documentation for more information about signing.
Expand Down
2 changes: 1 addition & 1 deletion samples/cs/minibzip2/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

[assembly: AssemblyVersion("0.85.2.324")]
[assembly: AssemblyVersion("0.85.2.329")]

[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile("")]
Expand Down
2 changes: 1 addition & 1 deletion samples/cs/minigzip/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

[assembly: AssemblyVersion("0.85.2.324")]
[assembly: AssemblyVersion("0.85.2.329")]

[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile("")]
Expand Down
2 changes: 1 addition & 1 deletion samples/cs/sz/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
// You can specify all values by your own or you can build default build and revision
// numbers with the '*' character (the default):

[assembly: AssemblyVersion("0.85.2.324")]
[assembly: AssemblyVersion("0.85.2.329")]

// The following attributes specify the key for the sign of your assembly. See the
// .NET Framework documentation for more information about signing.
Expand Down
2 changes: 1 addition & 1 deletion samples/cs/tar/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
// You can specify all values by your own or you can build default build and revision
// numbers with the '*' character (the default):

[assembly: AssemblyVersion("0.85.2.324")]
[assembly: AssemblyVersion("0.85.2.329")]

// The following attributes specify the key for the sign of your assembly. See the
// .NET Framework documentation for more information about signing.
Expand Down
2 changes: 1 addition & 1 deletion samples/cs/zf/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:

[assembly: AssemblyVersion("0.85.2.324")]
[assembly: AssemblyVersion("0.85.2.329")]

//
// In order to sign your assembly you must specify a key to use. Refer to the
Expand Down
2 changes: 1 addition & 1 deletion src/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
[assembly: AssemblyCopyright("Copyright 2001-2007 Mike Krueger, John Reilly")]
[assembly: AssemblyTrademark("Copyright 2001-2007 Mike Krueger, John Reilly")]

[assembly: AssemblyVersion("0.85.2.324")]
[assembly: AssemblyVersion("0.85.2.329")]
[assembly: AssemblyInformationalVersionAttribute("0.85.2")]


Expand Down
1 change: 1 addition & 0 deletions src/Zip/ZipFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1105,6 +1105,7 @@ long TestLocalHeader(ZipEntry entry, HeaderTest tests)
}

// Crc valid for empty entry.
// This will also apply to streamed entries where size isnt known and the header cant be patched
if ( (size == 0) && (compressedSize == 0) ) {
if ( crcValue != 0 ) {
throw new ZipException("Invalid CRC for empty entry");
Expand Down
21 changes: 14 additions & 7 deletions src/Zip/ZipOutputStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,10 @@ public class ZipOutputStream : DeflaterOutputStream
long crcPatchPos = -1;
long sizePatchPos = -1;

// Default of off is backwards compatible and doesnt dump on
// XP's built in compression which cnat handle it
UseZip64 useZip64_ = UseZip64.Off;
// Default is dynamic which is not backwards compatible and can cause problems
// with XP's built in compression which cant read Zip64 archives.
// However it does avoid the situation were a large file is added and cannot be completed correctly.
UseZip64 useZip64_ = UseZip64.Dynamic;
#endregion

#region Constructors
Expand Down Expand Up @@ -188,7 +189,7 @@ public int GetLevel()
/// <summary>
/// Get / set a value indicating how Zip64 Extension usage is determined when adding entries.
/// </summary>
UseZip64 UseZip64
public UseZip64 UseZip64
{
get { return useZip64_; }
set { useZip64_ = value; }
Expand Down Expand Up @@ -340,6 +341,7 @@ public void PutNextEntry(ZipEntry entry)
entry.CompressionMethod = (CompressionMethod)method;

curMethod = method;
sizePatchPos = -1;

if ( (useZip64_ == UseZip64.On) || ((entry.Size < 0) && (useZip64_ == UseZip64.Dynamic)) ) {
entry.ForceZip64();
Expand Down Expand Up @@ -375,7 +377,7 @@ public void PutNextEntry(ZipEntry entry)
}

// For local header both sizes appear in Zip64 Extended Information
if ( entry.LocalHeaderRequiresZip64 ) {
if ( entry.LocalHeaderRequiresZip64 && patchEntryHeader ) {
WriteLeInt(-1);
WriteLeInt(-1);
}
Expand All @@ -393,7 +395,7 @@ public void PutNextEntry(ZipEntry entry)

ZipExtraData ed = new ZipExtraData(entry.ExtraData);

if ( entry.LocalHeaderRequiresZip64 ) {
if (entry.LocalHeaderRequiresZip64 && (headerInfoAvailable || patchEntryHeader)) {
ed.StartNewEntry();
if (headerInfoAvailable) {
ed.AddLeLong(entry.Size);
Expand Down Expand Up @@ -474,7 +476,7 @@ public void CloseEntry()
base.Finish();
}

long csize = curMethod == CompressionMethod.Deflated ? def.TotalOut : size;
long csize = (curMethod == CompressionMethod.Deflated) ? def.TotalOut : size;

if (curEntry.Size < 0) {
curEntry.Size = size;
Expand Down Expand Up @@ -509,6 +511,11 @@ public void CloseEntry()
WriteLeInt((int)curEntry.Crc);

if ( curEntry.LocalHeaderRequiresZip64 ) {

if ( sizePatchPos == -1 ) {
throw new ZipException("Entry requires zip64 but this has been turned off");
}

baseOutputStream.Seek(sizePatchPos, SeekOrigin.Begin);
WriteLeLong(curEntry.Size);
WriteLeLong(curEntry.CompressedSize);
Expand Down
2 changes: 1 addition & 1 deletion tests/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
// You can specify all values by your own or you can build default build and revision
// numbers with the '*' character (the default):

[assembly: AssemblyVersion("0.85.2.324")]
[assembly: AssemblyVersion("0.85.2.329")]

// The following attributes specify the key for the sign of your assembly. See the
// .NET Framework documentation for more information about signing.
Expand Down
Loading

0 comments on commit 090fee6

Please sign in to comment.