@@ -1371,6 +1371,7 @@ public void FileStreamNotClosedWhenNotOwner()
13711371 /// Check that input stream is closed when construction fails and leaveOpen is false
13721372 /// </summary>
13731373 [ Test ]
1374+ [ Category ( "Zip" ) ]
13741375 public void StreamClosedOnError ( )
13751376 {
13761377 var ms = new TrackedMemoryStream ( new byte [ 32 ] ) ;
@@ -1397,6 +1398,7 @@ public void StreamClosedOnError()
13971398 /// Check that input stream is not closed when construction fails and leaveOpen is true
13981399 /// </summary>
13991400 [ Test ]
1401+ [ Category ( "Zip" ) ]
14001402 public void StreamNotClosedOnError ( )
14011403 {
14021404 var ms = new TrackedMemoryStream ( new byte [ 32 ] ) ;
@@ -1418,5 +1420,66 @@ public void StreamNotClosedOnError()
14181420 Assert . IsTrue ( blewUp , "Should have failed to load the file" ) ;
14191421 Assert . IsFalse ( ms . IsClosed , "Underlying stream should NOT be closed" ) ;
14201422 }
1423+
1424+ [ Test ]
1425+ [ Category ( "Zip" ) ]
1426+ public void HostSystemPersistedFromOutputStream ( )
1427+ {
1428+ using ( var ms = new MemoryStream ( ) )
1429+ {
1430+ var fileName = "testfile" ;
1431+
1432+ using ( var zos = new ZipOutputStream ( ms ) { IsStreamOwner = false } )
1433+ {
1434+ var source = new StringMemoryDataSource ( "foo" ) ;
1435+ zos . PutNextEntry ( new ZipEntry ( fileName ) { HostSystem = ( int ) HostSystemID . Unix } ) ;
1436+ source . GetSource ( ) . CopyTo ( zos ) ;
1437+ zos . CloseEntry ( ) ;
1438+ zos . Finish ( ) ;
1439+ }
1440+
1441+ ms . Seek ( 0 , SeekOrigin . Begin ) ;
1442+
1443+ using ( var zis = new ZipFile ( ms ) )
1444+ {
1445+ var ze = zis . GetEntry ( fileName ) ;
1446+ Assert . NotNull ( ze ) ;
1447+
1448+ Assert . AreEqual ( ( int ) HostSystemID . Unix , ze . HostSystem ) ;
1449+ Assert . AreEqual ( ZipConstants . VersionMadeBy , ze . VersionMadeBy ) ;
1450+ }
1451+ }
1452+ }
1453+
1454+ [ Test ]
1455+ [ Category ( "Zip" ) ]
1456+ public void HostSystemPersistedFromZipFile ( )
1457+ {
1458+ using ( var ms = new MemoryStream ( ) )
1459+ {
1460+ var fileName = "testfile" ;
1461+
1462+ using ( var zof = new ZipFile ( ms , true ) )
1463+ {
1464+ var ze = zof . EntryFactory . MakeFileEntry ( fileName , false ) ;
1465+ ze . HostSystem = ( int ) HostSystemID . Unix ;
1466+
1467+ zof . BeginUpdate ( ) ;
1468+ zof . Add ( new StringMemoryDataSource ( "foo" ) , ze ) ;
1469+ zof . CommitUpdate ( ) ;
1470+ }
1471+
1472+ ms . Seek ( 0 , SeekOrigin . Begin ) ;
1473+
1474+ using ( var zis = new ZipFile ( ms ) )
1475+ {
1476+ var ze = zis . GetEntry ( fileName ) ;
1477+ Assert . NotNull ( ze ) ;
1478+
1479+ Assert . AreEqual ( ( int ) HostSystemID . Unix , ze . HostSystem ) ;
1480+ Assert . AreEqual ( ZipConstants . VersionMadeBy , ze . VersionMadeBy ) ;
1481+ }
1482+ }
1483+ }
14211484 }
14221485}
0 commit comments