/
Packfile.cs
35 lines (28 loc) · 1.1 KB
/
Packfile.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System;
using System.Collections.Generic;
using System.IO;
namespace ThomasJepp.SaintsRow.Packfiles
{
public static class Packfile
{
public static IPackfile FromStream(Stream stream, bool isStr2)
{
stream.Seek(0, SeekOrigin.Begin);
uint descriptor = stream.ReadUInt32();
if (descriptor != 0x51890ACE)
throw new Exception("The input is not a packfile!");
uint version = stream.ReadUInt32();
switch (version)
{
case 0x04: // Saints Row 2
return new Packfiles.Version04.Packfile(stream);
case 0x06: // Saints Row: The Third
return new Packfiles.Version06.Packfile(stream, isStr2);
case 0x0A: // Saints Row IV & Saints Row: Gat out of Hell
return new Packfiles.Version0A.Packfile(stream, isStr2);
default:
throw new Exception(String.Format("Unsupported packfile version: {0:X4}", version));
}
}
}
}