예제 #1
0
 public void CollectData()
 {
     if (Data == null)
     {
         Data = new DataSection(true);
     }
 }
예제 #2
0
        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);
                }
            }
        }
예제 #3
0
 private void CollectObjectData(DataSection data, CodeObject code)
 {
 }