mirror of
https://github.com/crskycode/GARbro.git
synced 2024-12-24 20:04:13 +08:00
(GetSerializedSchemeVersion): moved header reading to separate method.
This commit is contained in:
parent
653ee4685d
commit
526485c720
@ -254,15 +254,9 @@ namespace GameRes
|
|||||||
|
|
||||||
public void DeserializeScheme (Stream input)
|
public void DeserializeScheme (Stream input)
|
||||||
{
|
{
|
||||||
using (var reader = new BinaryReader (input, System.Text.Encoding.UTF8, true))
|
int version = GetSerializedSchemeVersion (input);
|
||||||
{
|
|
||||||
var header = reader.ReadChars (SchemeID.Length);
|
|
||||||
if (!header.SequenceEqual (SchemeID))
|
|
||||||
throw new FormatException ("Invalid serialization file");
|
|
||||||
int version = reader.ReadInt32();
|
|
||||||
if (version <= CurrentSchemeVersion)
|
if (version <= CurrentSchemeVersion)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
using (var zs = new ZLibStream (input, CompressionMode.Decompress, true))
|
using (var zs = new ZLibStream (input, CompressionMode.Decompress, true))
|
||||||
{
|
{
|
||||||
var bin = new BinaryFormatter();
|
var bin = new BinaryFormatter();
|
||||||
@ -307,6 +301,17 @@ namespace GameRes
|
|||||||
using (var zs = new ZLibStream (output, CompressionMode.Compress, true))
|
using (var zs = new ZLibStream (output, CompressionMode.Compress, true))
|
||||||
bin.Serialize (zs, db);
|
bin.Serialize (zs, db);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int GetSerializedSchemeVersion (Stream input)
|
||||||
|
{
|
||||||
|
using (var reader = new BinaryReader (input, System.Text.Encoding.UTF8, true))
|
||||||
|
{
|
||||||
|
var header = reader.ReadChars (SchemeID.Length);
|
||||||
|
if (!header.SequenceEqual (SchemeID))
|
||||||
|
throw new FormatException ("Invalid serialization file");
|
||||||
|
return reader.ReadInt32();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user