Improvements and bug fixes.

This commit is contained in:
Razmoth
2022-10-08 20:35:11 +04:00
parent e7fd546f28
commit e0014854ba
6 changed files with 40 additions and 34 deletions

View File

@@ -31,35 +31,38 @@ namespace AssetStudio
}
public static void FromFile(string path)
{
Logger.Info(string.Format("Parsing...."));
try
if (!string.IsNullOrEmpty(path))
{
Clear();
using (var stream = File.OpenRead(path))
Logger.Info(string.Format("Parsing...."));
try
{
var bytes = new byte[stream.Length];
var count = stream.Read(bytes, 0, bytes.Length);
Clear();
if (count != bytes.Length)
throw new Exception("Error While Reading AssetIndex");
var json = Encoding.UTF8.GetString(bytes);
var obj = JsonConvert.DeserializeObject<AssetIndex>(json);
if (obj != null)
using (var stream = File.OpenRead(path))
{
MapToResourceIndex(obj);
var bytes = new byte[stream.Length];
var count = stream.Read(bytes, 0, bytes.Length);
if (count != bytes.Length)
throw new Exception("Error While Reading AssetIndex");
var json = Encoding.UTF8.GetString(bytes);
var obj = JsonConvert.DeserializeObject<AssetIndex>(json);
if (obj != null)
{
MapToResourceIndex(obj);
}
}
}
catch (Exception e)
{
Logger.Error("AssetIndex was not loaded");
Console.WriteLine(e.ToString());
return;
}
Logger.Info("Loaded !!");
}
catch (Exception e)
{
Logger.Error("AssetIndex was not loaded");
Console.WriteLine(e.ToString());
return;
}
Logger.Info("Loaded !!");
}
public static void Clear()
{