static BuildReportTool.SizePart[] ParseSizePartsFromString(string editorLogPath)
{
// now parse the build parts to an array of `BuildReportTool.SizePart`
List<BuildReportTool.SizePart> buildSizes = new List<BuildReportTool.SizePart>();
const string SIZE_PARTS_KEY = "Textures ";
foreach (string line in DldUtil.BigFileReader.ReadFile(editorLogPath, SIZE_PARTS_KEY))
{
// blank line signifies end of dll list
if (string.IsNullOrEmpty(line) || line == "\n" || line == "\r\n")
{
break;
}
//Debug.Log("ParseSizePartsFromString: " + line);
string b = line;
string gotName = "???";
string gotSize = "?";
string gotPercent = "?";
Match match = Regex.Match(b, @"^[a-z \t]+[^0-9]", RegexOptions.IgnoreCase);
if (match.Success)
{
gotName = match.Groups[0].Value;
gotName = gotName.Trim();
if (gotName == "Scripts") gotName = "Script DLLs";
//Debug.Log(" name? " + gotName);
}
match = Regex.Match(b, @"[0-9.]+ (kb|mb|b|gb)", RegexOptions.IgnoreCase);
if (match.Success)
{
gotSize = match.Groups[0].Value.ToUpper();
//Debug.Log(" size? " + gotSize);
}
match = Regex.Match(b, @"[0-9.]+%", RegexOptions.IgnoreCase);
if (match.Success)
{
gotPercent = match.Groups[0].Value;
gotPercent = gotPercent.Substring(0, gotPercent.Length-1);
//Debug.Log(" percent? " + gotPercent);
}
BuildReportTool.SizePart inPart = new BuildReportTool.SizePart();
inPart.Name = gotName;
inPart.Size = gotSize;
inPart.Percentage = Double.Parse(gotPercent);
inPart.DerivedSize = BuildReportTool.Util.GetApproxSizeFromString(gotSize);
buildSizes.Add(inPart);
if (line.IndexOf("100.0%") != -1)
{
break;
}
}
return buildSizes.ToArray();
}