Skip to content

Commit 43fd81e

Browse files
bjorgpiksel
authored andcommitted
Merge PR icsharpcode#325: Ability to mimic a zip file created by a Linux file-system
* respect the VersionMadeBy property of ZipEntry * correctly set HostSystem without clearing version
1 parent afcccb0 commit 43fd81e

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

src/ICSharpCode.SharpZipLib/Zip/ZipEntry.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ public int HostSystem
526526

527527
set
528528
{
529-
versionMadeBy &= 0xff;
529+
versionMadeBy &= 0x00ff;
530530
versionMadeBy |= (ushort)((value & 0xff) << 8);
531531
}
532532
}

src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ public ZipFile(string name)
428428
public ZipFile(FileStream file) :
429429
this(file, false)
430430
{
431-
431+
432432
}
433433

434434
/// <summary>
@@ -489,7 +489,7 @@ public ZipFile(FileStream file, bool leaveOpen)
489489
public ZipFile(Stream stream) :
490490
this(stream, false)
491491
{
492-
492+
493493
}
494494

495495
/// <summary>
@@ -2157,7 +2157,7 @@ private int WriteCentralDirectoryHeader(ZipEntry entry)
21572157
WriteLEInt(ZipConstants.CentralHeaderSignature);
21582158

21592159
// Version made by
2160-
WriteLEShort(ZipConstants.VersionMadeBy);
2160+
WriteLEShort((entry.HostSystem << 8) | entry.VersionMadeBy);
21612161

21622162
// Version required to extract
21632163
WriteLEShort(entry.Version);

src/ICSharpCode.SharpZipLib/Zip/ZipOutputStream.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ public override void Finish()
750750
foreach (ZipEntry entry in entries)
751751
{
752752
WriteLeInt(ZipConstants.CentralHeaderSignature);
753-
WriteLeShort(ZipConstants.VersionMadeBy);
753+
WriteLeShort((entry.HostSystem << 8) | entry.VersionMadeBy);
754754
WriteLeShort(entry.Version);
755755
WriteLeShort(entry.Flags);
756756
WriteLeShort((short)entry.CompressionMethodForHeader);

0 commit comments

Comments
 (0)