MCPcopy Create free account
hub / github.com/esengine/esengine / seek

Method seek

packages/fairygui/src/utils/ByteBuffer.ts:80–108  ·  view source on GitHub ↗

* Seek to position * 定位到指定位置

(indexTablePos: number, blockIndex: number)

Source from the content-addressed store, hash-verified

78 * 定位到指定位置
79 */
80 public seek(indexTablePos: number, blockIndex: number): boolean {
81 const tmp = this._position;
82 this._position = indexTablePos;
83
84 const segCount = this.getUint8();
85 if (blockIndex < segCount) {
86 const useShort = this.getUint8() === 1;
87 let newPos: number;
88
89 if (useShort) {
90 this._position = indexTablePos + 2 + 2 * blockIndex;
91 newPos = this.getUint16();
92 } else {
93 this._position = indexTablePos + 2 + 4 * blockIndex;
94 newPos = this.getUint32();
95 }
96
97 if (newPos > 0) {
98 this._position = indexTablePos + newPos;
99 return true;
100 } else {
101 this._position = tmp;
102 return false;
103 }
104 } else {
105 this._position = tmp;
106 return false;
107 }
108 }
109
110 // Read methods | 读取方法
111

Callers

nothing calls this directly

Calls 3

getUint8Method · 0.95
getUint16Method · 0.95
getUint32Method · 0.95

Tested by

no test coverage detected