public Model(Stream stream, string path) : base(path) { base._data = Data = new CueFormat(this, stream, path); SetIgnoredName("Range.wav"); if (Data.FileSize > 512 * 1024) { IssueModel.Add("Oversized file", Severity.Fatal); return; } Data.fBuf = new byte[Data.FileSize]; Data.fbs.Position = 0; if (Data.fbs.Read(Data.fBuf, 0, (int)Data.FileSize) != Data.FileSize) { IssueModel.Add("Read error", Severity.Fatal); return; } Data.Codepage = Encoding.GetEncoding(1252); int fIx = 0, fIx1 = 0, fIx2 = 0, bIxNS = -1, quoteIx1 = -1, quoteIx2 = -1; for (int line = 1;;) { if (fIx < Data.fBuf.Length) { byte ch = Data.fBuf[fIx]; ++fIx; if (ch == (byte)'\r') { fIx2 = fIx < Data.fBuf.Length && Data.fBuf[fIx] == (byte)'\n' ? fIx + 1 : fIx; } else if (ch == (byte)'\n') { fIx2 = fIx; } else { if (ch == '\"') { if (quoteIx1 < 0) { quoteIx1 = fIx; } else if (quoteIx2 < 0) { quoteIx2 = fIx - 1; } } else if (bIxNS < 0 && ch != ' ') { bIxNS = fIx - 1; } continue; } } else { fIx2 = fIx; } if (ConvertTo.StartsWithAscii(Data.fBuf, bIxNS, "CATALOG ")) { Data.Catalog = FormatBase.Cp1252.GetString(Data.fBuf, bIxNS + 8, fIx2 - bIxNS - 8).Trim(null); if (Data.Catalog.Length != 13) { IssueModel.Add("Invalid CATALOG."); } } else if (ConvertTo.StartsWithAscii(Data.fBuf, bIxNS, "FILE ")) { if (quoteIx2 <= quoteIx1) { IssueModel.Add("Malformed FILE."); } else { string quoted = FormatBase.Cp1252.GetString(Data.fBuf, quoteIx1, quoteIx2 - quoteIx1); FilesModel.Add1252(quoted, quoteIx1, quoteIx2 - quoteIx1); } } fIx = fIx1 = bIxNS = fIx2; quoteIx1 = quoteIx2 = -1; ++line; if (fIx >= Data.fBuf.Length) { break; } } }