MCPcopy Create free account
hub / github.com/ZeppelinMC/Zeppelin / readString

Method readString

protocol/nbt/staticReader.go:55–70  ·  view source on GitHub ↗

reads a string prefixed by a short of its length

()

Source from the content-addressed store, hash-verified

53
54// reads a string prefixed by a short of its length
55func (r StaticReader) readString() (string, error) {
56 length, err := r.readShort()
57 if err != nil {
58 return "", err
59 }
60 if length < 0 {
61 return "", fmt.Errorf("negative length for make (read string)")
62 }
63 var data = make([]byte, length)
64
65 if _, err := r.r.Read(data); err != nil {
66 return "", err
67 }
68
69 return unsafe.String(unsafe.SliceData(data), len(data)), nil //*(*string)(unsafe.Pointer(&data)), nil
70}
71
72func (r StaticReader) ReadRoot(withName bool) (typeId byte, name string, err error) {
73 typeId, err = r.readByte()

Callers 10

ReadRootMethod · 0.95
ByteMethod · 0.95
ShortMethod · 0.95
IntMethod · 0.95
LongMethod · 0.95
StringMethod · 0.95
CompoundMethod · 0.95
ReadStringMapMethod · 0.45
ReadAllMethod · 0.45
ReadMethod · 0.45

Calls 3

readShortMethod · 0.95
ReadMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected