From 79cb847f46928401b152bc052addad3458565e7a Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Fri, 8 Jul 2016 23:33:34 +0200 Subject: Comments --- meta/info.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'meta/info.go') diff --git a/meta/info.go b/meta/info.go index 57aa937..bdcb894 100644 --- a/meta/info.go +++ b/meta/info.go @@ -59,7 +59,7 @@ func (i Info) GetPieces() []Piece { return p } -// Open N-th file and allocate required path +// Open N-th file and allocate required path on demand func (i Info) Open(n int) (*os.File, error) { var p string if len(i.Files) == 0 { @@ -78,6 +78,9 @@ func (i Info) Offset(piece int) int { return i.PieceLength * piece } +// FindFile looks up first file # corresponding to offset in gross buffer +// If piece is bigger the next file(s) with offset 0 shall be used to +// fit a piece into func (i Info) FindFile(off int) (int, int) { for n, l := range i.Files { if l.Length > off { @@ -93,6 +96,11 @@ func (i Info) FindFile(off int) (int, int) { * |----|----|----|----|----|----|----|--| pieces * |-|----|--|----|----------|-|----|----| files * 0 1 2 3 4 5 6 7 #file + * + * 0 2 3 4 #piece + * |--------|--------|--------|-----| pieces + * |-|--|--|-|--|--|-------------|--| files + * 0 1 2 3 4 5 6 7 #file */ // FIXME WriteAt ... -- cgit v1.2.3