@@ -1654,7 +1654,7 @@ private void AddUpdate(ZipUpdate update)
1654
1654
/// <param name="useUnicodeText">Ensure Unicode text is used for name and comment for this entry.</param>
1655
1655
/// <exception cref="ArgumentNullException">Argument supplied is null.</exception>
1656
1656
/// <exception cref="ObjectDisposedException">ZipFile has been closed.</exception>
1657
- /// <exception cref="ArgumentOutOfRangeException ">Compression method is not supported.</exception>
1657
+ /// <exception cref="NotImplementedException ">Compression method is not supported for creating entries .</exception>
1658
1658
public void Add ( string fileName , CompressionMethod compressionMethod , bool useUnicodeText )
1659
1659
{
1660
1660
if ( fileName == null )
@@ -1667,11 +1667,7 @@ public void Add(string fileName, CompressionMethod compressionMethod, bool useUn
1667
1667
throw new ObjectDisposedException ( "ZipFile" ) ;
1668
1668
}
1669
1669
1670
- if ( ! ZipEntry . IsCompressionMethodSupported ( compressionMethod ) )
1671
- {
1672
- throw new ArgumentOutOfRangeException ( nameof ( compressionMethod ) ) ;
1673
- }
1674
-
1670
+ CheckSupportedCompressionMethod ( compressionMethod ) ;
1675
1671
CheckUpdating ( ) ;
1676
1672
contentsEdited_ = true ;
1677
1673
@@ -1688,19 +1684,15 @@ public void Add(string fileName, CompressionMethod compressionMethod, bool useUn
1688
1684
/// <param name="fileName">The name of the file to add.</param>
1689
1685
/// <param name="compressionMethod">The compression method to use.</param>
1690
1686
/// <exception cref="ArgumentNullException">ZipFile has been closed.</exception>
1691
- /// <exception cref="ArgumentOutOfRangeException">The compression method is not supported.</exception>
1687
+ /// <exception cref="NotImplementedException">Compression method is not supported for creating entries .</exception>
1692
1688
public void Add ( string fileName , CompressionMethod compressionMethod )
1693
1689
{
1694
1690
if ( fileName == null )
1695
1691
{
1696
1692
throw new ArgumentNullException ( nameof ( fileName ) ) ;
1697
1693
}
1698
1694
1699
- if ( ! ZipEntry . IsCompressionMethodSupported ( compressionMethod ) )
1700
- {
1701
- throw new ArgumentOutOfRangeException ( nameof ( compressionMethod ) ) ;
1702
- }
1703
-
1695
+ CheckSupportedCompressionMethod ( compressionMethod ) ;
1704
1696
CheckUpdating ( ) ;
1705
1697
contentsEdited_ = true ;
1706
1698
@@ -1774,6 +1766,7 @@ public void Add(IStaticDataSource dataSource, string entryName)
1774
1766
/// <param name="dataSource">The source of the data for this entry.</param>
1775
1767
/// <param name="entryName">The name to give to the entry.</param>
1776
1768
/// <param name="compressionMethod">The compression method to use.</param>
1769
+ /// <exception cref="NotImplementedException">Compression method is not supported for creating entries.</exception>
1777
1770
public void Add ( IStaticDataSource dataSource , string entryName , CompressionMethod compressionMethod )
1778
1771
{
1779
1772
if ( dataSource == null )
@@ -1786,6 +1779,7 @@ public void Add(IStaticDataSource dataSource, string entryName, CompressionMetho
1786
1779
throw new ArgumentNullException ( nameof ( entryName ) ) ;
1787
1780
}
1788
1781
1782
+ CheckSupportedCompressionMethod ( compressionMethod ) ;
1789
1783
CheckUpdating ( ) ;
1790
1784
1791
1785
ZipEntry entry = EntryFactory . MakeFileEntry ( entryName , false ) ;
@@ -1801,6 +1795,7 @@ public void Add(IStaticDataSource dataSource, string entryName, CompressionMetho
1801
1795
/// <param name="entryName">The name to give to the entry.</param>
1802
1796
/// <param name="compressionMethod">The compression method to use.</param>
1803
1797
/// <param name="useUnicodeText">Ensure Unicode text is used for name and comments for this entry.</param>
1798
+ /// <exception cref="NotImplementedException">Compression method is not supported for creating entries.</exception>
1804
1799
public void Add ( IStaticDataSource dataSource , string entryName , CompressionMethod compressionMethod , bool useUnicodeText )
1805
1800
{
1806
1801
if ( dataSource == null )
@@ -1813,6 +1808,7 @@ public void Add(IStaticDataSource dataSource, string entryName, CompressionMetho
1813
1808
throw new ArgumentNullException ( nameof ( entryName ) ) ;
1814
1809
}
1815
1810
1811
+ CheckSupportedCompressionMethod ( compressionMethod ) ;
1816
1812
CheckUpdating ( ) ;
1817
1813
1818
1814
ZipEntry entry = EntryFactory . MakeFileEntry ( entryName , false ) ;
@@ -1853,6 +1849,7 @@ public void Add(ZipEntry entry)
1853
1849
/// <exception cref="NotSupportedException">
1854
1850
/// The encryption method specified in <paramref name="entry"/> is unsupported.
1855
1851
/// </exception>
1852
+ /// <exception cref="NotImplementedException">Compression method is not supported for creating entries.</exception>
1856
1853
public void Add ( IStaticDataSource dataSource , ZipEntry entry )
1857
1854
{
1858
1855
if ( entry == null )
@@ -1872,6 +1869,7 @@ public void Add(IStaticDataSource dataSource, ZipEntry entry)
1872
1869
throw new NotSupportedException ( "Creation of AES encrypted entries is not supported" ) ;
1873
1870
}
1874
1871
1872
+ CheckSupportedCompressionMethod ( entry . CompressionMethod ) ;
1875
1873
CheckUpdating ( ) ;
1876
1874
1877
1875
AddUpdate ( new ZipUpdate ( dataSource , entry ) ) ;
@@ -1894,6 +1892,18 @@ public void AddDirectory(string directoryName)
1894
1892
AddUpdate ( new ZipUpdate ( UpdateCommand . Add , dirEntry ) ) ;
1895
1893
}
1896
1894
1895
+ /// <summary>
1896
+ /// Check if the specified compression method is supported for adding a new entry.
1897
+ /// </summary>
1898
+ /// <param name="compressionMethod">The compression method for the new entry.</param>
1899
+ private void CheckSupportedCompressionMethod ( CompressionMethod compressionMethod )
1900
+ {
1901
+ if ( compressionMethod != CompressionMethod . Deflated && compressionMethod != CompressionMethod . Stored )
1902
+ {
1903
+ throw new NotImplementedException ( "Compression method not supported" ) ;
1904
+ }
1905
+ }
1906
+
1897
1907
#endregion Adding Entries
1898
1908
1899
1909
#region Modifying Entries
0 commit comments