From 5d4696de4ca2e85efee8be377640621b378d0112 Mon Sep 17 00:00:00 2001 From: morkt Date: Mon, 8 Sep 2014 07:36:20 +0400 Subject: [PATCH] cosmetic changes. --- ArcFormats/ArcAMI.cs | 5 ++++- ArcFormats/ArcKogado.cs | 5 ++++- ArcFormats/ArcNPA.cs | 4 ++-- ArcFormats/ArcYPF.cs | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/ArcFormats/ArcAMI.cs b/ArcFormats/ArcAMI.cs index 6fe9b5f3..f1491eb8 100644 --- a/ArcFormats/ArcAMI.cs +++ b/ArcFormats/ArcAMI.cs @@ -294,9 +294,12 @@ namespace GameRes.Formats return packed_size; } + static Lazy s_grp_format = new Lazy (() => + FormatCatalog.Instance.ImageFormats.OfType().FirstOrDefault()); + uint WriteImageEntry (PackedEntry entry, Stream input, Stream output) { - var grp = FormatCatalog.Instance.ImageFormats.OfType().FirstOrDefault(); + var grp = s_grp_format.Value; if (null == grp) // probably never happens throw new FileFormatException ("GRP image encoder not available"); bool is_grp = grp.Signature == FormatCatalog.ReadSignature (input); diff --git a/ArcFormats/ArcKogado.cs b/ArcFormats/ArcKogado.cs index b73ede91..63ef044a 100644 --- a/ArcFormats/ArcKogado.cs +++ b/ArcFormats/ArcKogado.cs @@ -174,12 +174,15 @@ namespace GameRes.Formats.Kogado try { string name = Path.GetFileNameWithoutExtension (entry.Name); - string ext = Path.GetExtension (entry.Name).TrimStart ('.').ToLowerInvariant(); + string ext = Path.GetExtension (entry.Name); byte[] name_buf = new byte[0x15]; byte[] ext_buf = new byte[3]; encoding.GetBytes (name, 0, name.Length, name_buf, 0); if (!string.IsNullOrEmpty (ext)) + { + ext = ext.TrimStart ('.').ToLowerInvariant(); encoding.GetBytes (ext, 0, ext.Length, ext_buf, 0); + } var out_entry = new OutputEntry { Name = entry.Name, diff --git a/ArcFormats/ArcNPA.cs b/ArcFormats/ArcNPA.cs index 00a07a37..2e396fa8 100644 --- a/ArcFormats/ArcNPA.cs +++ b/ArcFormats/ArcNPA.cs @@ -594,9 +594,9 @@ namespace GameRes.Formats.NitroPlus private bool m_read_mode; private long m_base_pos; - public override bool CanRead { get { return m_read_mode; } } + public override bool CanRead { get { return m_read_mode && m_stream.CanRead; } } public override bool CanSeek { get { return m_stream.CanSeek; } } - public override bool CanWrite { get { return !m_read_mode; } } + public override bool CanWrite { get { return !m_read_mode && m_stream.CanWrite; } } public override long Length { get { return m_stream.Length - m_base_pos; } } public override long Position { diff --git a/ArcFormats/ArcYPF.cs b/ArcFormats/ArcYPF.cs index 376d97f7..efcfd011 100644 --- a/ArcFormats/ArcYPF.cs +++ b/ArcFormats/ArcYPF.cs @@ -222,7 +222,7 @@ namespace GameRes.Formats.YuRis writer.Write (name_len); writer.Write (entry.IndexName); writer.Write (entry.FileType); - writer.Write ((byte)(entry.IsPacked ? 1 : 0)); + writer.Write (entry.IsPacked); writer.Write (entry.UnpackedSize); writer.Write (entry.Size); writer.Write ((uint)entry.Offset);