/* ----------------------------------------------------------------- */ /// /// CreateTarOption /// /// <summary> /// TarOption オブジェクトに変換します。 /// </summary> /// /* ----------------------------------------------------------------- */ private static TarOption CreateTarOption(ArchiveRtSettings src, ArchiveSettings common) => new TarOption { CompressionLevel = src.CompressionLevel, CompressionMethod = src.CompressionMethod, ThreadCount = src.ThreadCount, };
/* ----------------------------------------------------------------- */ /// /// GetFormat /// /// <summary> /// 圧縮フォーマットを取得します。 /// </summary> /// /* ----------------------------------------------------------------- */ private Format GetFormat() { var f = Request.Format; switch (f) { case Format.Tar: case Format.Zip: case Format.SevenZip: case Format.Sfx: RtSettings = new ArchiveRtSettings(f, Settings.IO); break; case Format.BZip2: case Format.GZip: case Format.XZ: RtSettings = new ArchiveRtSettings(Format.Tar, Settings.IO); RtSettings.CompressionMethod = f.ToMethod(); break; default: RaiseRtSettingsRequested(); break; } return(RtSettings.Format); }
/* ----------------------------------------------------------------- */ /// /// CreateSfxOption /// /// <summary> /// SfxOption オブジェクトに変換します。 /// </summary> /// /* ----------------------------------------------------------------- */ private static SfxOption CreateSfxOption(ArchiveRtSettings src, ArchiveSettings common) => new SfxOption { CompressionLevel = src.CompressionLevel, CompressionMethod = src.CompressionMethod, ThreadCount = src.ThreadCount, Module = src.SfxModule, };
/* ----------------------------------------------------------------- */ /// /// CreateZipOption /// /// <summary> /// ZipOption オブジェクトに変換します。 /// </summary> /// /* ----------------------------------------------------------------- */ private static ZipOption CreateZipOption(ArchiveRtSettings src, ArchiveSettings common) => new ZipOption { CompressionLevel = src.CompressionLevel, CompressionMethod = src.CompressionMethod, EncryptionMethod = src.EncryptionMethod, ThreadCount = src.ThreadCount, CodePage = common.UseUtf8 ? CodePage.Utf8 : CodePage.Oem, };
/* ----------------------------------------------------------------- */ /// /// RaiseRtSettingsRequested /// /// <summary> /// RuntimeSettingsRequested イベントを発生させます。 /// </summary> /// /* ----------------------------------------------------------------- */ private void RaiseRtSettingsRequested() { var info = IO.Get(Request.Sources.First()); var path = IO.Combine(info.DirectoryName, $"{info.NameWithoutExtension}.zip"); var e = new QueryEventArgs <string, ArchiveRtSettings>(path, true); RtSettingsRequested?.Invoke(this, e); if (e.Cancel) { throw new OperationCanceledException(); } RtSettings = e.Result; }
/* ----------------------------------------------------------------- */ /// /// ToOption /// /// <summary> /// ArchiveOption オブジェクトに変換します。 /// </summary> /// /// <param name="src">実行時圧縮設定</param> /// <param name="common">圧縮に関するユーザ設定</param> /// /* ----------------------------------------------------------------- */ public static ArchiveOption ToOption(this ArchiveRtSettings src, ArchiveSettings common) { switch (src.Format) { case Format.Zip: return(CreateZipOption(src, common)); case Format.SevenZip: return(CreateSevenZipOption(src, common)); case Format.Sfx: return(CreateSfxOption(src, common)); case Format.Tar: return(CreateTarOption(src, common)); default: return(CreateArchiveOption(src, common)); } }
public void Convert_ToOption() { var asm = Assembly.GetExecutingAssembly(); var dest = new ArchiveRtSettings(IO) { CompressionLevel = CompressionLevel.High, CompressionMethod = CompressionMethod.Ppmd, EncryptionMethod = EncryptionMethod.Aes192, Format = Format.GZip, Password = "******", Path = "dummy", SfxModule = string.Empty, ThreadCount = 3, }.ToOption(new SettingsFolder(asm, IO)); Assert.That(dest.CompressionLevel, Is.EqualTo(CompressionLevel.High)); Assert.That(dest.ThreadCount, Is.EqualTo(3)); }
/* ----------------------------------------------------------------- */ /// /// ToOption /// /// <summary> /// ArchiveOption オブジェクトに変換します。 /// </summary> /// /// <param name="src">実行時圧縮設定</param> /// <param name="settings">ユーザ設定</param> /// /* ----------------------------------------------------------------- */ public static ArchiveOption ToOption(this ArchiveRtSettings src, SettingsFolder settings) => ToOption(src, settings.Value.Archive);
/* ----------------------------------------------------------------- */ /// /// CreateArchiveOption /// /// <summary> /// ArchiveOption オブジェクトに変換します。 /// </summary> /// /* ----------------------------------------------------------------- */ private static ArchiveOption CreateArchiveOption(ArchiveRtSettings src, ArchiveSettings common) => new ArchiveOption { CompressionLevel = src.CompressionLevel, ThreadCount = src.ThreadCount, };