(ZIP): added filename encoding setting.

This commit is contained in:
morkt 2018-02-18 03:55:00 +04:00
parent 118504e620
commit 816e392d03
9 changed files with 52 additions and 1 deletions

View File

@ -44,6 +44,11 @@ namespace GameRes.Formats.PalmTree
static readonly byte[] ArDirSignature = { (byte)'A', (byte)'R', 5, 6 }; static readonly byte[] ArDirSignature = { (byte)'A', (byte)'R', 5, 6 };
public ArcOpener ()
{
Settings = null;
}
public override ArcFile TryOpen (ArcView file) public override ArcFile TryOpen (ArcView file)
{ {
if (-1 == SearchForSignature (file, ArDirSignature)) if (-1 == SearchForSignature (file, ArDirSignature))

View File

@ -100,6 +100,13 @@ namespace GameRes.Formats.PkWare
static readonly byte[] PkDirSignature = { (byte)'P', (byte)'K', 5, 6 }; static readonly byte[] PkDirSignature = { (byte)'P', (byte)'K', 5, 6 };
public ZipOpener ()
{
Settings = new[] { ZipEncoding };
}
EncodingSetting ZipEncoding = new EncodingSetting ("ZIPEncodingCP");
public override ArcFile TryOpen (ArcView file) public override ArcFile TryOpen (ArcView file)
{ {
if (-1 == SearchForSignature (file, PkDirSignature)) if (-1 == SearchForSignature (file, PkDirSignature))
@ -182,7 +189,7 @@ namespace GameRes.Formats.PkWare
Encoding enc; Encoding enc;
try try
{ {
enc = Encoding.GetEncoding (Properties.Settings.Default.ZIPEncodingCP); enc = ZipEncoding.Get<Encoding>();
} }
catch catch
{ {

View File

@ -4,6 +4,7 @@
// //
using System.ComponentModel.Composition; using System.ComponentModel.Composition;
using System.Text;
using GameRes.Formats.Strings; using GameRes.Formats.Strings;
namespace GameRes.Formats namespace GameRes.Formats
@ -24,6 +25,18 @@ namespace GameRes.Formats
} }
} }
internal class EncodingSetting : LocalResourceSetting
{
public override object Value {
get { return Encoding.GetEncoding ((int)base.Value); }
set { base.Value = ((Encoding)value).CodePage; }
}
public EncodingSetting () { }
public EncodingSetting (string name) : base (name) { }
}
[Export(typeof(ISettingsManager))] [Export(typeof(ISettingsManager))]
internal class SettingsManager : ISettingsManager internal class SettingsManager : ISettingsManager
{ {

View File

@ -863,6 +863,15 @@ namespace GameRes.Formats.Strings {
} }
} }
/// <summary>
/// Looks up a localized string similar to Default file names encoding.
/// </summary>
public static string ZIPEncodingCP {
get {
return ResourceManager.GetString("ZIPEncodingCP", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Archive content is encrypted.. /// Looks up a localized string similar to Archive content is encrypted..
/// </summary> /// </summary>

View File

@ -495,4 +495,7 @@ Choose encryption scheme or enter a passphrase.</comment>
<value>Fix Ogg files checksums</value> <value>Fix Ogg files checksums</value>
<comment>Translation pending</comment> <comment>Translation pending</comment>
</data> </data>
<data name="ZIPEncodingCP" xml:space="preserve">
<value>Default file names encoding</value>
</data>
</root> </root>

View File

@ -395,4 +395,8 @@
<value>Fix Ogg files checksums</value> <value>Fix Ogg files checksums</value>
<comment>Translation pending</comment> <comment>Translation pending</comment>
</data> </data>
<data name="ZIPEncodingCP" xml:space="preserve">
<value>Default file names encoding</value>
<comment>translation pending</comment>
</data>
</root> </root>

View File

@ -395,4 +395,7 @@ Choose encryption scheme or enter a passphrase.</value>
<data name="OGGFixCrc" xml:space="preserve"> <data name="OGGFixCrc" xml:space="preserve">
<value>Fix Ogg files checksums</value> <value>Fix Ogg files checksums</value>
</data> </data>
<data name="ZIPEncodingCP" xml:space="preserve">
<value>Default file names encoding</value>
</data>
</root> </root>

View File

@ -347,6 +347,9 @@
<data name="YPFTryGuess" xml:space="preserve"> <data name="YPFTryGuess" xml:space="preserve">
<value>Попытаться подобрать</value> <value>Попытаться подобрать</value>
</data> </data>
<data name="ZIPEncodingCP" xml:space="preserve">
<value>Кодировка имён файлов</value>
</data>
<data name="ZIPEncryptedNotice" xml:space="preserve"> <data name="ZIPEncryptedNotice" xml:space="preserve">
<value>Содержимое архива зашифровано.</value> <value>Содержимое архива зашифровано.</value>
</data> </data>

View File

@ -396,4 +396,8 @@
<value>Fix Ogg files checksums</value> <value>Fix Ogg files checksums</value>
<comment>Translation pending</comment> <comment>Translation pending</comment>
</data> </data>
<data name="ZIPEncodingCP" xml:space="preserve">
<value>Default file names encoding</value>
<comment>translation pending</comment>
</data>
</root> </root>