in sumdb/tlog/tile.go [192:234]
func ParseTilePath(path string) (Tile, error) {
f := strings.Split(path, "/")
if len(f) < 4 || f[0] != "tile" {
return Tile{}, &badPathError{path}
}
h, err1 := strconv.Atoi(f[1])
isData := false
if f[2] == "data" {
isData = true
f[2] = "0"
}
l, err2 := strconv.Atoi(f[2])
if err1 != nil || err2 != nil || h < 1 || l < 0 || h > 30 {
return Tile{}, &badPathError{path}
}
w := 1 << uint(h)
if dotP := f[len(f)-2]; strings.HasSuffix(dotP, ".p") {
ww, err := strconv.Atoi(f[len(f)-1])
if err != nil || ww <= 0 || ww >= w {
return Tile{}, &badPathError{path}
}
w = ww
f[len(f)-2] = dotP[:len(dotP)-len(".p")]
f = f[:len(f)-1]
}
f = f[3:]
n := int64(0)
for _, s := range f {
nn, err := strconv.Atoi(strings.TrimPrefix(s, "x"))
if err != nil || nn < 0 || nn >= pathBase {
return Tile{}, &badPathError{path}
}
n = n*pathBase + int64(nn)
}
if isData {
l = -1
}
t := Tile{H: h, L: l, N: n, W: w}
if path != t.Path() {
return Tile{}, &badPathError{path}
}
return t, nil
}