Apply Zip encoding patch from GordonJ

This commit is contained in:
Matt Nadareski
2021-09-08 22:52:23 -07:00
parent 00e0663ff3
commit 20b5266c54
4 changed files with 27 additions and 5 deletions

View File

@@ -33,6 +33,11 @@ namespace Compress.ZipFile
public ZipStatus ZipStatus { get; set; }
public Zip()
{
ZipUtils.EncodeSetup();
}
public int LocalFilesCount()
{
return _localFiles.Count;

View File

@@ -7,7 +7,15 @@ namespace Compress.ZipFile
{
// according to the zip documents, zip filesname are stored as MS-DOS Code Page 437.
// (Unless the uncode flag is set, in which case they are stored as UTF-8.
private static Encoding enc = Encoding.GetEncoding(437);
private static Encoding enc = null;
public static void EncodeSetup()
{
if (enc != null)
return;
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
enc = Encoding.GetEncoding(437);
}
public static string GetString(byte[] byteArr)
{

View File

@@ -15,7 +15,8 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="SharpCompress" Version="0.26.0" />
<PackageReference Include="SharpCompress" Version="0.28.3" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="5.0.0" />
</ItemGroup>
</Project>

View File

@@ -20,8 +20,16 @@ namespace SabreTools.IO
// If the input is not seekable, just return the current position
if (!input.CanSeek)
{
try
{
return input.Position;
}
catch
{
return -1;
}
}
// Attempt to seek to the offset
try
{