aboutsummaryrefslogtreecommitdiff
path: root/meta/torrent.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2016-07-02 05:11:12 +0200
committerDimitri Sokolyuk <demon@dim13.org>2016-07-02 05:11:12 +0200
commit749665df56b396d8af0b398dcb205b09660c2601 (patch)
treef348ff9d737eeb4cca43698d4281c178ad7dfc75 /meta/torrent.go
parent6edbf5b19304f483cf5869d9e8d9ce35ea650a5f (diff)
More examples
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
}
/*