(ArcFile.OpenView): ensure that length supplied to ArcView is always greater than zero.

This commit is contained in:
morkt 2016-06-11 06:38:47 +04:00
parent da42dcdd9d
commit 08cd673408
6 changed files with 38 additions and 2 deletions

View File

@ -161,9 +161,22 @@ namespace GameRes
if (stream.CanSeek) if (stream.CanSeek)
size = (uint)stream.Length; size = (uint)stream.Length;
else if (null != packed_entry && packed_entry.IsPacked) else if (null != packed_entry && packed_entry.IsPacked)
{
size = packed_entry.UnpackedSize; size = packed_entry.UnpackedSize;
if (0 == size)
{
using (var copy = new MemoryStream())
{
stream.CopyTo (copy);
copy.Position = 0;
return new ArcView (copy, entry.Name, (uint)copy.Length);
}
}
}
else else
size = entry.Size; size = entry.Size;
if (0 == size)
throw new FileSizeException (Strings.garStrings.MsgFileIsEmpty);
return new ArcView (stream, entry.Name, size); return new ArcView (stream, entry.Name, size);
} }
} }

View File

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // 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 // Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated. // the code is regenerated.
@ -60,6 +60,15 @@ namespace GameRes.Strings {
} }
} }
/// <summary>
/// Looks up a localized string similar to File is empty.
/// </summary>
public static string MsgFileIsEmpty {
get {
return ResourceManager.GetString("MsgFileIsEmpty", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to File is too large. /// Looks up a localized string similar to File is too large.
/// </summary> /// </summary>

View File

@ -117,6 +117,10 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="MsgFileIsEmpty" xml:space="preserve">
<value>File is empty</value>
<comment>translation pending</comment>
</data>
<data name="MsgFileTooLarge" xml:space="preserve"> <data name="MsgFileTooLarge" xml:space="preserve">
<value>파일이 너무 큽니다</value> <value>파일이 너무 큽니다</value>
</data> </data>
@ -135,4 +139,4 @@
<data name="MsgUnknownFormat" xml:space="preserve"> <data name="MsgUnknownFormat" xml:space="preserve">
<value>파일을 리소스 아카이브로 열지 못하였습니다</value> <value>파일을 리소스 아카이브로 열지 못하였습니다</value>
</data> </data>
</root> </root>

View File

@ -117,6 +117,9 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="MsgFileIsEmpty" xml:space="preserve">
<value>File is empty</value>
</data>
<data name="MsgFileTooLarge" xml:space="preserve"> <data name="MsgFileTooLarge" xml:space="preserve">
<value>File is too large</value> <value>File is too large</value>
</data> </data>

View File

@ -117,6 +117,9 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="MsgFileIsEmpty" xml:space="preserve">
<value>Файл пуст</value>
</data>
<data name="MsgFileTooLarge" xml:space="preserve"> <data name="MsgFileTooLarge" xml:space="preserve">
<value>Слишком большой размер файла</value> <value>Слишком большой размер файла</value>
</data> </data>

View File

@ -117,6 +117,10 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="MsgFileIsEmpty" xml:space="preserve">
<value>File is empty</value>
<comment>translation pending</comment>
</data>
<data name="MsgFileTooLarge" xml:space="preserve"> <data name="MsgFileTooLarge" xml:space="preserve">
<value>文件尺寸太大。</value> <value>文件尺寸太大。</value>
</data> </data>