aboutsummaryrefslogtreecommitdiff
path: root/meta/torrent.go
diff options
context:
space:
mode:
Diffstat (limited to 'meta/torrent.go')
-rw-r--r--meta/torrent.go24
1 files changed, 2 insertions, 22 deletions
diff --git a/meta/torrent.go b/meta/torrent.go
index 2e2c144..140b992 100644
--- a/meta/torrent.go
+++ b/meta/torrent.go
@@ -5,7 +5,6 @@ import (
"crypto/sha1"
"errors"
"fmt"
- "log"
"os"
"path"
"time"
@@ -101,32 +100,13 @@ func (i Info) FullPath(n int) (string, error) {
// piece-to-file mapping:
// piece # -> [ { file #, off, len }, ... ]
-type pieceToFile map[int][]struct {
- fd os.File
- offset int
- length int
-}
-
-func (i Info) FindFile(chunk, offset int) int {
- if i.isSingleFile() {
- return 0
- }
- return 0
-}
-
-func (i Info) Offset(piece int) int {
- return i.PieceLength * piece
-}
-
func (i Info) FileOffset(piece int) (int, int) {
off := i.PieceLength * piece
for n, l := range i.Files {
- if l.Length < off {
- off -= l.Length
- } else {
- log.Println(n, off, i.PieceLength-off)
+ if l.Length > off {
return n, off
}
+ off -= l.Length
}
return 0, off
}