aboutsummaryrefslogtreecommitdiff
path: root/meta/torrent.go
diff options
context:
space:
mode:
Diffstat (limited to 'meta/torrent.go')
-rw-r--r--meta/torrent.go11
1 files changed, 6 insertions, 5 deletions
diff --git a/meta/torrent.go b/meta/torrent.go
index 65e74bd..886668f 100644
--- a/meta/torrent.go
+++ b/meta/torrent.go
@@ -98,15 +98,16 @@ func (i Info) Offset(piece int) int {
return i.PieceLength * piece
}
-func (i Info) FileOffset(piece int) (n, off int) {
- var l File
- off = i.PieceLength * piece
- for n, l = range i.Files {
+func (i Info) FileOffset(piece int) (int, int, bool) {
+ off := i.PieceLength * piece
+ for n, l := range i.Files {
if l.Length < off {
off -= l.Length
+ } else {
+ return n, off, off+i.PieceLength > i.Length
}
}
- return n, off
+ return 0, off, false
}
/*