using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using Roblox.BinaryFormat;
using Roblox.XmlFormat;
namespace Roblox
{
///
/// Interface which represents a RobloxFile implementation.
///
public interface IRobloxFile
{
Instance Contents { get; }
void ReadFile(byte[] buffer);
}
///
/// Represents a loaded *.rbxl/*.rbxm Roblox file.
/// All of the surface-level Instances are stored in the RobloxFile's Trunk property.
///
public class RobloxFile : IRobloxFile
{
public bool Initialized { get; private set; }
public IRobloxFile InnerFile { get; private set; }
public Instance Contents => InnerFile.Contents;
public void ReadFile(byte[] buffer)
{
if (!Initialized)
{
if (buffer.Length > 14)
{
string header = Encoding.UTF7.GetString(buffer, 0, 14);
IRobloxFile file = null;
if (header == BinaryRobloxFile.MagicHeader)
file = new BinaryRobloxFile();
else if (header.StartsWith("