public static Node FromStreamV2(BinaryReader reader, int index, StringBlock stringBlock, byte[] dataBlock) { reader.BaseStream.Seek(index * 17, SeekOrigin.Begin); var nameOffset = reader.ReadInt32(); var siblingIndex = reader.ReadInt32(); var name = stringBlock.GetString(nameOffset); var type = reader.ReadByte(); if (type == 0) { return(IntermediateNode.IntermediateV2(siblingIndex, name, reader, stringBlock, dataBlock)); } else { return(LeafNode.LeafV2(siblingIndex, name, reader, type, dataBlock)); } }
public static Node FromStream(BinaryReader reader, int offset, StringBlock stringBlock, byte[] dataBlock) { if (reader == null) { throw new ArgumentNullException("reader"); } if (stringBlock == null) { throw new ArgumentNullException("stringBlock"); } if (dataBlock == null) { throw new ArgumentNullException("dataBlock"); } reader.BaseStream.Seek(offset, SeekOrigin.Begin); int peerOffset = reader.ReadInt32(); int nameOffset = reader.ReadInt32(); string name = stringBlock.GetString(nameOffset); NodeFlags flags = (NodeFlags)reader.ReadInt32(); if ((flags & NodeFlags.Intermediate) == NodeFlags.Intermediate) { return(new IntermediateNode(peerOffset, name, reader, stringBlock, dataBlock)); } else if ((flags & NodeFlags.Leaf) == NodeFlags.Leaf) { return(new LeafNode(peerOffset, name, reader, dataBlock)); } else { //throw new FileContentException(UtfFile.FILE_TYPE, "Neither required flag set. Flags: " + flags); return(new LeafNode(peerOffset, name, reader, dataBlock)); } }