]> Sergey Matveev's repositories - btrtrc.git/blob - storage/file-misc.go
cmd/btrtrc client
[btrtrc.git] / storage / file-misc.go
1 package storage
2
3 import (
4         "github.com/anacrolix/torrent/segments"
5 )
6
7 // Returns the minimum file lengths required for the given extent to exist on disk. Returns false if
8 // the extent is not covered by the files in the index.
9 func minFileLengthsForTorrentExtent(
10         fileSegmentsIndex segments.Index,
11         off, n int64,
12         each func(fileIndex int, length int64) bool,
13 ) bool {
14         return fileSegmentsIndex.Locate(segments.Extent{
15                 Start:  off,
16                 Length: n,
17         }, func(fileIndex int, segmentBounds segments.Extent) bool {
18                 return each(fileIndex, segmentBounds.Start+segmentBounds.Length)
19         })
20 }