(file string)
| 95 | const postEntrySize = 3 + 4 + 4 |
| 96 | |
| 97 | func Open(file string) *Index { |
| 98 | mm := mmap(file) |
| 99 | if len(mm.d) < 4*4+len(trailerMagic) || string(mm.d[len(mm.d)-len(trailerMagic):]) != trailerMagic { |
| 100 | corrupt() |
| 101 | } |
| 102 | n := uint32(len(mm.d) - len(trailerMagic) - 5*4) |
| 103 | ix := &Index{data: mm} |
| 104 | ix.pathData = ix.uint32(n) |
| 105 | ix.nameData = ix.uint32(n + 4) |
| 106 | ix.postData = ix.uint32(n + 8) |
| 107 | ix.nameIndex = ix.uint32(n + 12) |
| 108 | ix.postIndex = ix.uint32(n + 16) |
| 109 | ix.numName = int((ix.postIndex-ix.nameIndex)/4) - 1 |
| 110 | ix.numPost = int((n - ix.postIndex) / postEntrySize) |
| 111 | return ix |
| 112 | } |
| 113 | |
| 114 | // slice returns the slice of index data starting at the given byte offset. |
| 115 | // If n >= 0, the slice must have length at least n and is truncated to length n. |
searching dependent graphs…