git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1062 993157c7-ee19-0410-b2c4-bb4e9862e678
This commit is contained in:
@@ -33,15 +33,15 @@ namespace MixBrowser
|
||||
return;
|
||||
}
|
||||
|
||||
MixFile file = new MixFile(fn);
|
||||
Package file = new Package(fn);
|
||||
|
||||
if (File.Exists("files.txt"))
|
||||
foreach (string filename in File.ReadAllLines("files.txt"))
|
||||
MixEntry.AddStandardName(filename);
|
||||
PackageEntry.AddStandardName(filename);
|
||||
else
|
||||
Console.WriteLine("-- files.txt doesnt exist --");
|
||||
|
||||
foreach (MixEntry e in file.Content)
|
||||
foreach (PackageEntry e in file.Content)
|
||||
Console.WriteLine(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,8 +37,8 @@
|
||||
<Compile Include="Blowfish.cs" />
|
||||
<Compile Include="Format40.cs" />
|
||||
<Compile Include="Format80.cs" />
|
||||
<Compile Include="MixEntry.cs" />
|
||||
<Compile Include="MixFile.cs" />
|
||||
<Compile Include="PackageEntry.cs" />
|
||||
<Compile Include="Package.cs" />
|
||||
<Compile Include="Palette.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ShpReader.cs" />
|
||||
|
||||
@@ -5,18 +5,18 @@ using System.IO;
|
||||
|
||||
namespace OpenRa.FileFormats
|
||||
{
|
||||
public class MixFile
|
||||
public class Package
|
||||
{
|
||||
readonly string filename;
|
||||
readonly List<MixEntry> index;
|
||||
readonly List<PackageEntry> index;
|
||||
readonly bool isRmix, isEncrypted;
|
||||
|
||||
public ICollection<MixEntry> Content
|
||||
public ICollection<PackageEntry> Content
|
||||
{
|
||||
get { return index.AsReadOnly(); }
|
||||
}
|
||||
|
||||
public MixFile(string filename)
|
||||
public Package(string filename)
|
||||
{
|
||||
this.filename = filename;
|
||||
using (Stream s = File.OpenRead(filename))
|
||||
@@ -40,7 +40,7 @@ namespace OpenRa.FileFormats
|
||||
}
|
||||
}
|
||||
|
||||
List<MixEntry> ParseRaHeader(Stream s)
|
||||
List<PackageEntry> ParseRaHeader(Stream s)
|
||||
{
|
||||
if (!isEncrypted)
|
||||
{
|
||||
@@ -75,7 +75,7 @@ namespace OpenRa.FileFormats
|
||||
s.Position = headerStart;
|
||||
reader = new BinaryReader(s);
|
||||
|
||||
h = ReadUints(reader, 2 + numFiles * MixEntry.Size / 4);
|
||||
h = ReadUints(reader, 2 + numFiles * PackageEntry.Size / 4);
|
||||
decrypted = fish.Decrypt(h);
|
||||
|
||||
ms = new MemoryStream();
|
||||
@@ -98,23 +98,23 @@ namespace OpenRa.FileFormats
|
||||
return ret;
|
||||
}
|
||||
|
||||
List<MixEntry> ParseTdHeader(Stream s)
|
||||
List<PackageEntry> ParseTdHeader(Stream s)
|
||||
{
|
||||
List<MixEntry> items = new List<MixEntry>();
|
||||
List<PackageEntry> items = new List<PackageEntry>();
|
||||
|
||||
BinaryReader reader = new BinaryReader(s);
|
||||
ushort numFiles = reader.ReadUInt16();
|
||||
uint dataSize = reader.ReadUInt32();
|
||||
|
||||
for (int i = 0; i < numFiles; i++)
|
||||
items.Add(new MixEntry(reader));
|
||||
items.Add(new PackageEntry(reader));
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
public Stream GetContent(uint hash)
|
||||
{
|
||||
foreach( MixEntry e in index )
|
||||
foreach( PackageEntry e in index )
|
||||
if (e.Hash == hash)
|
||||
{
|
||||
using (Stream s = File.OpenRead(filename))
|
||||
@@ -126,7 +126,7 @@ namespace OpenRa.FileFormats
|
||||
if (isEncrypted)
|
||||
s.Seek(80, SeekOrigin.Current);
|
||||
|
||||
s.Seek(index.Count * MixEntry.Size + e.Offset, SeekOrigin.Current);
|
||||
s.Seek(index.Count * PackageEntry.Size + e.Offset, SeekOrigin.Current);
|
||||
byte[] data = new byte[ e.Length ];
|
||||
s.Read( data, 0, (int)e.Length );
|
||||
return new MemoryStream(data);
|
||||
@@ -138,7 +138,7 @@ namespace OpenRa.FileFormats
|
||||
|
||||
public Stream GetContent(string filename)
|
||||
{
|
||||
return GetContent(MixEntry.HashFilename(filename));
|
||||
return GetContent(PackageEntry.HashFilename(filename));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,13 +5,13 @@ using System.IO;
|
||||
|
||||
namespace OpenRa.FileFormats
|
||||
{
|
||||
public class MixEntry
|
||||
public class PackageEntry
|
||||
{
|
||||
public readonly uint Hash;
|
||||
public readonly uint Offset;
|
||||
public readonly uint Length;
|
||||
|
||||
public MixEntry(BinaryReader r)
|
||||
public PackageEntry(BinaryReader r)
|
||||
{
|
||||
Hash = r.ReadUInt32();
|
||||
Offset = r.ReadUInt32();
|
||||
Reference in New Issue
Block a user