| 23 | } |
| 24 | |
| 25 | func (this *FileHeader) BlockAt(offset int64) (blockInfo BlockInfo, ok bool) { |
| 26 | var l = len(this.BodyBlocks) |
| 27 | if l == 1 { |
| 28 | if this.BodyBlocks[0].Contains(offset) { |
| 29 | return this.BodyBlocks[0], true |
| 30 | } |
| 31 | return |
| 32 | } |
| 33 | |
| 34 | sort.Search(l, func(i int) bool { |
| 35 | if this.BodyBlocks[i].Contains(offset) { |
| 36 | blockInfo = this.BodyBlocks[i] |
| 37 | ok = true |
| 38 | return true |
| 39 | } |
| 40 | return this.BodyBlocks[i].OriginOffsetFrom > offset |
| 41 | }) |
| 42 | |
| 43 | return |
| 44 | } |
| 45 | |
| 46 | func (this *FileHeader) MaxOffset() int64 { |
| 47 | var l = len(this.BodyBlocks) |