Added write support for binary files!
Holy cow, this took a lot of work. I think I may need to do a few more things before I consider this a 1.0 release, but I'm glad to have finally overcome this hurdle!
This commit is contained in:
@ -2,24 +2,37 @@
|
||||
|
||||
namespace RobloxFiles.BinaryFormat.Chunks
|
||||
{
|
||||
public class META
|
||||
public class META : IBinaryFileChunk
|
||||
{
|
||||
public int NumEntries;
|
||||
public Dictionary<string, string> Data = new Dictionary<string, string>();
|
||||
|
||||
public META(BinaryRobloxFileChunk chunk)
|
||||
public void LoadFromReader(BinaryRobloxFileReader reader)
|
||||
{
|
||||
using (BinaryRobloxFileReader reader = chunk.GetDataReader())
|
||||
{
|
||||
NumEntries = reader.ReadInt32();
|
||||
BinaryRobloxFile file = reader.File;
|
||||
int numEntries = reader.ReadInt32();
|
||||
|
||||
for (int i = 0; i < NumEntries; i++)
|
||||
{
|
||||
string key = reader.ReadString();
|
||||
string value = reader.ReadString();
|
||||
Data.Add(key, value);
|
||||
}
|
||||
for (int i = 0; i < numEntries; i++)
|
||||
{
|
||||
string key = reader.ReadString();
|
||||
string value = reader.ReadString();
|
||||
Data.Add(key, value);
|
||||
}
|
||||
|
||||
file.META = this;
|
||||
}
|
||||
|
||||
public BinaryRobloxFileChunk SaveAsChunk(BinaryRobloxFileWriter writer)
|
||||
{
|
||||
writer.StartWritingChunk(this);
|
||||
writer.Write(Data.Count);
|
||||
|
||||
foreach (var kvPair in Data)
|
||||
{
|
||||
writer.WriteString(kvPair.Key);
|
||||
writer.WriteString(kvPair.Value);
|
||||
}
|
||||
|
||||
return writer.FinishWritingChunk();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user