(PFS): added option to select filenames encoding (#162)

This commit is contained in:
morkt 2018-03-11 21:12:58 +04:00
parent eafe023de9
commit 8016560d04
11 changed files with 52 additions and 3 deletions

View File

@ -135,6 +135,8 @@
<Compile Include="elf\ArcAi5DAT.cs" /> <Compile Include="elf\ArcAi5DAT.cs" />
<Compile Include="elf\ImageRMT.cs" /> <Compile Include="elf\ImageRMT.cs" />
<Compile Include="Emote\ImageDREF.cs" /> <Compile Include="Emote\ImageDREF.cs" />
<Compile Include="FC01\ArcPAK.cs" />
<Compile Include="FrontWing\ArcVAV.cs" />
<Compile Include="Groover\ArcPCG.cs" /> <Compile Include="Groover\ArcPCG.cs" />
<Compile Include="HCSystem\ArcPAK.cs" /> <Compile Include="HCSystem\ArcPAK.cs" />
<Compile Include="HCSystem\ImageOPF.cs" /> <Compile Include="HCSystem\ImageOPF.cs" />

View File

@ -23,11 +23,11 @@
// IN THE SOFTWARE. // IN THE SOFTWARE.
// //
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.Composition; using System.ComponentModel.Composition;
using System.IO; using System.IO;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Text;
namespace GameRes.Formats.Artemis namespace GameRes.Formats.Artemis
{ {
@ -42,9 +42,12 @@ namespace GameRes.Formats.Artemis
public PfsOpener () public PfsOpener ()
{ {
Extensions = new string[] { "pfs", "000", "001", "002", "003" }; Extensions = new string[] { "pfs", "000", "001", "002", "003", "004", "005" };
Settings = new[] { PfsEncoding };
} }
EncodingSetting PfsEncoding = new EncodingSetting ("PFSEncodingCP");
public override ArcFile TryOpen (ArcView file) public override ArcFile TryOpen (ArcView file)
{ {
if (!file.View.AsciiEqual (0, "pf")) if (!file.View.AsciiEqual (0, "pf"))
@ -65,7 +68,7 @@ namespace GameRes.Formats.Artemis
int count = file.View.ReadInt32 (7); int count = file.View.ReadInt32 (7);
if (!IsSaneCount (count) || 7L + index_size > file.MaxOffset) if (!IsSaneCount (count) || 7L + index_size > file.MaxOffset)
return null; return null;
var encoding = version >= 8 ? System.Text.Encoding.UTF8 : Encodings.cp932; var encoding = PfsEncoding.Get<Encoding>();
var index = file.View.ReadBytes (7, index_size); var index = file.View.ReadBytes (7, index_size);
int index_offset = 4; int index_offset = 4;
var dir = new List<Entry> (count); var dir = new List<Entry> (count);

View File

@ -741,5 +741,17 @@ namespace GameRes.Formats.Properties {
this["OGGFixCrc"] = value; this["OGGFixCrc"] = value;
} }
} }
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("65001")]
public int PFSEncodingCP {
get {
return ((int)(this["PFSEncodingCP"]));
}
set {
this["PFSEncodingCP"] = value;
}
}
} }
} }

View File

@ -182,5 +182,8 @@
<Setting Name="OGGFixCrc" Type="System.Boolean" Scope="User"> <Setting Name="OGGFixCrc" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value> <Value Profile="(Default)">False</Value>
</Setting> </Setting>
<Setting Name="PFSEncodingCP" Type="System.Int32" Scope="User">
<Value Profile="(Default)">65001</Value>
</Setting>
</Settings> </Settings>
</SettingsFile> </SettingsFile>

View File

@ -660,6 +660,15 @@ namespace GameRes.Formats.Strings {
} }
} }
/// <summary>
/// Looks up a localized string similar to Default file names encoding.
/// </summary>
public static string PFSEncodingCP {
get {
return ResourceManager.GetString("PFSEncodingCP", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Use default encryption scheme. /// Looks up a localized string similar to Use default encryption scheme.
/// </summary> /// </summary>

View File

@ -498,4 +498,7 @@ Choose encryption scheme or enter a passphrase.</comment>
<data name="ZIPEncodingCP" xml:space="preserve"> <data name="ZIPEncodingCP" xml:space="preserve">
<value>Default file names encoding</value> <value>Default file names encoding</value>
</data> </data>
<data name="PFSEncodingCP" xml:space="preserve">
<value>Default file names encoding</value>
</data>
</root> </root>

View File

@ -399,4 +399,8 @@
<value>Default file names encoding</value> <value>Default file names encoding</value>
<comment>translation pending</comment> <comment>translation pending</comment>
</data> </data>
<data name="PFSEncodingCP" xml:space="preserve">
<value>Default file names encoding</value>
<comment>translation pending</comment>
</data>
</root> </root>

View File

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

View File

@ -291,6 +291,9 @@
<data name="PDScrambleContents" xml:space="preserve"> <data name="PDScrambleContents" xml:space="preserve">
<value>Шифровать содержимое</value> <value>Шифровать содержимое</value>
</data> </data>
<data name="PFSEncodingCP" xml:space="preserve">
<value>Кодировка имён файлов</value>
</data>
<data name="QLIEDefaultScheme" xml:space="preserve"> <data name="QLIEDefaultScheme" xml:space="preserve">
<value>"Старый" метод шифрования</value> <value>"Старый" метод шифрования</value>
</data> </data>

View File

@ -400,4 +400,8 @@
<value>Default file names encoding</value> <value>Default file names encoding</value>
<comment>translation pending</comment> <comment>translation pending</comment>
</data> </data>
<data name="PFSEncodingCP" xml:space="preserve">
<value>Default file names encoding</value>
<comment>translation pending</comment>
</data>
</root> </root>

View File

@ -184,6 +184,9 @@
<setting name="OGGFixCrc" serializeAs="String"> <setting name="OGGFixCrc" serializeAs="String">
<value>False</value> <value>False</value>
</setting> </setting>
<setting name="PFSEncodingCP" serializeAs="String">
<value>65001</value>
</setting>
</GameRes.Formats.Properties.Settings> </GameRes.Formats.Properties.Settings>
</userSettings> </userSettings>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" /></startup> <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" /></startup>