+func (m *Manifest) ManifestStreamForPath(path string) string {
+ manifestForPath := ""
+ locators := []string{}
+ for ms := range m.StreamIter() {
+ if ms.StreamName != "./"+path {
+ continue
+ }
+
+ locators = append(locators, ms.Blocks...)
+
+ currentName := ""
+ currentSpan := []uint64{0, 0}
+ for _, fss := range ms.FileStreamSegments {
+ if fss.Name != currentName && currentName != "" {
+ manifestForPath += fmt.Sprintf("%v", currentSpan[0]) + ":" + fmt.Sprintf("%v", currentSpan[1]) + ":" + currentName + " "
+ }
+
+ if fss.Name != currentName {
+ currentName = fss.Name
+ currentSpan = []uint64{0, 0}
+ }
+
+ if currentSpan[1] == 0 {
+ currentSpan = []uint64{fss.SegPos, fss.SegLen}
+ } else {
+ if currentSpan[1] == fss.SegPos {
+ currentSpan[1] += fss.SegLen
+ } else {
+ manifestForPath += fmt.Sprintf("%v", currentSpan[0]) + ":" + fmt.Sprintf("%v", currentSpan[1]+fss.SegLen) + ":" + fss.Name + " "
+ currentSpan = []uint64{fss.SegPos, fss.SegPos + fss.SegLen}
+ }
+ }
+ }
+ manifestForPath += fmt.Sprintf("%v", currentSpan[0]) + ":" + fmt.Sprintf("%v", currentSpan[1]) + ":" + currentName + " "
+ }
+
+ if len(locators) > 0 {
+ return "./" + path + " " + strings.Join(locators, " ") + " " + manifestForPath
+ }
+
+ return ""
+}
+