public void CollectData() { if (Data == null) { Data = new DataSection(true); } }
public void LoadFromStream(Stream stream) { using var br = new BinaryReader(stream); // TJS2 var tag = br.ReadChars(4).ToRealString(); if (tag != FILE_TAG_LE) { throw new TjsFormatException(TjsBadFormatReason.Header, "Signature wrong"); } // 100'\0' var ver = br.ReadChars(3).ToRealString(); if (ver != VER_TAG_LE) { Debug.WriteLine($"Unknown version: {ver}"); //throw new TjsFormatException(TjsBadFormatReason.Version, "Version unsupported"); } br.ReadChar(); //file size int size = br.ReadInt32(); if (size != stream.Length) { Debug.WriteLine($"File size incorrect: Expect {size}, Actual {stream.Length}"); } bool dataLoaded = false; bool objsLoaded = false; while (br.PeekChar() != -1 && (!dataLoaded || !objsLoaded)) { tag = br.ReadChars(4).ToRealString(); size = br.ReadInt32(); if (tag == DATA_TAG_LE && !dataLoaded) //DATA { Data = new DataSection(); Data.Read(br); dataLoaded = true; } else if (tag == OBJS_TAG_LE && !objsLoaded) //OBJS { ReadObjects(br); objsLoaded = true; } else { br.BaseStream.Seek(size, SeekOrigin.Current); } } }
private void CollectObjectData(DataSection data, CodeObject code) { }