예제 #1
0
        protected void LoadFileInternal(Stream fileStream)
        {
            // Make sure the stream is at the beginning
            fileStream.Seek(0, SeekOrigin.Begin);

            // Make sure the first byte in this file is the tag for a TAG_Compound
            if (fileStream.ReadByte() == (int)NbtTagType.TAG_Compound)
            {
                var rootCompound = new NbtCompound();
                rootCompound.ReadTag(fileStream);

                RootTag = rootCompound;
            }
            else
            {
                throw new InvalidDataException("File format does not start with a TAG_Compound");
            }
        }
예제 #2
0
        void LoadFromStreamInternal([NotNull] Stream stream, [CanBeNull] TagSelector tagSelector)
        {
            // Make sure the first byte in this file is the tag for a TAG_Compound
            int firstByte = stream.ReadByte();

            if (firstByte < 0)
            {
                throw new EndOfStreamException();
            }
            if (firstByte != (int)NbtTagType.Compound)
            {
                throw new NbtFormatException("Given NBT stream does not start with a TAG_Compound");
            }
            var reader = new NbtBinaryReader(stream, BigEndian)
            {
                Selector = tagSelector
            };

            var rootCompound = new NbtCompound(reader.ReadString());

            rootCompound.ReadTag(reader);
            RootTag = rootCompound;
        }
예제 #3
0
파일: NbtFile.cs 프로젝트: johndpalm/fNbt
        void LoadFromStreamInternal([NotNull] Stream stream, [CanBeNull] TagSelector tagSelector)
        {
            // Make sure the first byte in this file is the tag for a TAG_Compound
            if (stream.ReadByte() != (int)NbtTagType.Compound) {
                throw new NbtFormatException("Given NBT stream does not start with a TAG_Compound");
            }
            var reader = new NbtBinaryReader(stream, BigEndian) {
                Selector = tagSelector
            };

            var rootCompound = new NbtCompound(reader.ReadString());
            rootCompound.ReadTag(reader);
            RootTag = rootCompound;
        }
예제 #4
0
        void LoadFromStreamInternal( [NotNull] Stream fileStream )
        {
            if( fileStream == null ) throw new ArgumentNullException( "fileStream" );

            // Make sure the first byte in this file is the tag for a TAG_Compound
            if( fileStream.ReadByte() != (int)NbtTagType.Compound ) {
                throw new NbtFormatException( "File format does not start with a TAG_Compound" );
            }

            var rootCompound = new NbtCompound();
            rootCompound.ReadTag( new NbtReader( fileStream ), true );
            RootTag = rootCompound;
        }