Roblox-File-Format/UnitTest/Program.cs

83 lines
2.2 KiB
C#
Raw Normal View History

using System;
using System.Diagnostics;
using System.Linq;
namespace RobloxFiles.UnitTest
{
static class Program
{
static void PrintTreeImpl(Instance inst, int stack = 0)
{
string padding = "";
string extension = "";
for (int i = 0; i < stack; i++)
padding += '\t';
switch (inst.ClassName)
{
case "Script":
2021-03-20 02:38:13 +00:00
{
extension = ".server.lua";
break;
2021-03-20 02:38:13 +00:00
}
case "LocalScript":
2021-03-20 02:38:13 +00:00
{
extension = ".client.lua";
break;
2021-03-20 02:38:13 +00:00
}
case "ModuleScript":
2021-03-20 02:38:13 +00:00
{
extension = ".lua";
break;
2021-03-20 02:38:13 +00:00
}
}
Console.WriteLine($"{padding}{inst.Name}{extension}");
var children = inst
.GetChildren()
.ToList();
children.ForEach(child => PrintTreeImpl(child, stack + 1));
}
static void PrintTree(string path)
{
Console.WriteLine("Opening file...");
RobloxFile target = RobloxFile.Open(path);
foreach (Instance child in target.GetChildren())
PrintTreeImpl(child);
Debugger.Break();
}
2021-03-20 02:38:13 +00:00
[STAThread]
static void Main(string[] args)
{
2020-10-30 20:07:11 +00:00
RobloxFile.LogErrors = true;
2020-06-30 00:06:14 +00:00
if (args.Length > 0)
{
string path = args[0];
PrintTree(path);
2020-06-30 00:06:14 +00:00
}
else
{
RobloxFile bin = RobloxFile.Open(@"Files\Binary.rbxl");
RobloxFile xml = RobloxFile.Open(@"Files\Xml.rbxlx");
2020-06-30 00:06:14 +00:00
Console.WriteLine("Files opened! Pausing execution for debugger analysis...");
Debugger.Break();
bin.Save(@"Files\Binary_SaveTest.rbxl");
xml.Save(@"Files\Xml_SaveTest.rbxlx");
2020-06-30 00:06:14 +00:00
Console.WriteLine("Files saved! Pausing execution for debugger analysis...");
Debugger.Break();
}
}
}
}