mirror of
https://github.com/crskycode/GARbro.git
synced 2024-12-24 03:44:13 +08:00
added ZIP settings for archive creation.
also ignore directories in entries list.
This commit is contained in:
parent
55d72aa9bb
commit
66dc447ddb
@ -30,6 +30,8 @@ using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using GameRes.Formats.Properties;
|
||||
using GameRes.Formats.Strings;
|
||||
|
||||
namespace GameRes.Formats.PkWare
|
||||
{
|
||||
@ -97,7 +99,8 @@ namespace GameRes.Formats.PkWare
|
||||
var zip = new ZipArchive (input, ZipArchiveMode.Read, false, Encodings.cp932);
|
||||
try
|
||||
{
|
||||
var dir = zip.Entries.Select (z => new ZipEntry (z) as Entry).ToList();
|
||||
var dir = zip.Entries.Where (z => !z.FullName.EndsWith ("/"))
|
||||
.Select (z => new ZipEntry (z) as Entry).ToList();
|
||||
return new PkZipArchive (file, this, dir, zip);
|
||||
}
|
||||
catch
|
||||
@ -147,9 +150,18 @@ namespace GameRes.Formats.PkWare
|
||||
|
||||
public override ResourceOptions GetDefaultOptions ()
|
||||
{
|
||||
Encoding enc;
|
||||
try
|
||||
{
|
||||
enc = Encoding.GetEncoding (Settings.Default.ZIPEncodingCP);
|
||||
}
|
||||
catch
|
||||
{
|
||||
enc = Encodings.cp932;
|
||||
}
|
||||
return new ZipOptions {
|
||||
CompressionLevel = CompressionLevel.Optimal,
|
||||
FileNameEncoding = Encodings.cp932,
|
||||
CompressionLevel = Settings.Default.ZIPCompression,
|
||||
FileNameEncoding = enc,
|
||||
};
|
||||
}
|
||||
|
||||
@ -158,7 +170,8 @@ namespace GameRes.Formats.PkWare
|
||||
public override void Create (Stream output, IEnumerable<Entry> list, ResourceOptions options,
|
||||
EntryCallback callback)
|
||||
{
|
||||
var zip_options = (ZipOptions)options;
|
||||
var zip_options = GetOptions<ZipOptions> (options);
|
||||
int callback_count = 0;
|
||||
using (var zip = new ZipArchive (output, ZipArchiveMode.Create, true, zip_options.FileNameEncoding))
|
||||
{
|
||||
foreach (var entry in list)
|
||||
@ -167,6 +180,8 @@ namespace GameRes.Formats.PkWare
|
||||
using (var input = File.OpenRead (entry.Name))
|
||||
using (var zip_file = zip_entry.Open())
|
||||
{
|
||||
if (null != callback)
|
||||
callback (++callback_count, entry, arcStrings.MsgAddingFile);
|
||||
input.CopyTo (zip_file);
|
||||
}
|
||||
}
|
||||
|
26
ArcFormats/Properties/Settings.Designer.cs
generated
26
ArcFormats/Properties/Settings.Designer.cs
generated
@ -1,7 +1,7 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.34209
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
@ -477,5 +477,29 @@ namespace GameRes.Formats.Properties {
|
||||
this["YPFScheme"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("Optimal")]
|
||||
public global::System.IO.Compression.CompressionLevel ZIPCompression {
|
||||
get {
|
||||
return ((global::System.IO.Compression.CompressionLevel)(this["ZIPCompression"]));
|
||||
}
|
||||
set {
|
||||
this["ZIPCompression"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("932")]
|
||||
public int ZIPEncodingCP {
|
||||
get {
|
||||
return ((int)(this["ZIPEncodingCP"]));
|
||||
}
|
||||
set {
|
||||
this["ZIPEncodingCP"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -116,5 +116,11 @@
|
||||
<Setting Name="YPFScheme" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)" />
|
||||
</Setting>
|
||||
<Setting Name="ZIPCompression" Type="System.IO.Compression.CompressionLevel" Scope="User">
|
||||
<Value Profile="(Default)">Optimal</Value>
|
||||
</Setting>
|
||||
<Setting Name="ZIPEncodingCP" Type="System.Int32" Scope="User">
|
||||
<Value Profile="(Default)">932</Value>
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
@ -118,6 +118,12 @@
|
||||
<setting name="YPFScheme" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
<setting name="ZIPCompression" serializeAs="String">
|
||||
<value>Optimal</value>
|
||||
</setting>
|
||||
<setting name="ZIPEncodingCP" serializeAs="String">
|
||||
<value>932</value>
|
||||
</setting>
|
||||
</GameRes.Formats.Properties.Settings>
|
||||
</userSettings>
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration>
|
||||
|
Loading…
x
Reference in New Issue
Block a user