mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Apply Zip encoding patch from GordonJ
This commit is contained in:
@@ -33,6 +33,11 @@ namespace Compress.ZipFile
|
|||||||
|
|
||||||
public ZipStatus ZipStatus { get; set; }
|
public ZipStatus ZipStatus { get; set; }
|
||||||
|
|
||||||
|
public Zip()
|
||||||
|
{
|
||||||
|
ZipUtils.EncodeSetup();
|
||||||
|
}
|
||||||
|
|
||||||
public int LocalFilesCount()
|
public int LocalFilesCount()
|
||||||
{
|
{
|
||||||
return _localFiles.Count;
|
return _localFiles.Count;
|
||||||
|
|||||||
@@ -7,7 +7,15 @@ namespace Compress.ZipFile
|
|||||||
{
|
{
|
||||||
// according to the zip documents, zip filesname are stored as MS-DOS Code Page 437.
|
// 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.
|
// (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)
|
public static string GetString(byte[] byteArr)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,7 +15,8 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<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>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -17,11 +17,19 @@ namespace SabreTools.IO
|
|||||||
// If the stream is null, don't even try
|
// If the stream is null, don't even try
|
||||||
if (input == null)
|
if (input == null)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
// If the input is not seekable, just return the current position
|
// If the input is not seekable, just return the current position
|
||||||
if (!input.CanSeek)
|
if (!input.CanSeek)
|
||||||
return input.Position;
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return input.Position;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
// Attempt to seek to the offset
|
// Attempt to seek to the offset
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user