aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2016-07-05 21:26:02 +0200
committerDimitri Sokolyuk <demon@dim13.org>2016-07-05 21:26:02 +0200
commited314439d5acc345e5101d61afb366c55c2921f8 (patch)
treebf2be4fd0faa87baf5acf5f1994dff12fab8cc68
parentf32fa29a71224dbe65ef57b7d4dd1a09ed0e7310 (diff)
wip
-rw-r--r--meta/torrent.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/meta/torrent.go b/meta/torrent.go
index 63ac390..9d77e5c 100644
--- a/meta/torrent.go
+++ b/meta/torrent.go
@@ -18,6 +18,10 @@ type File struct {
Path []string `bencode:"path"`
}
+func (f File) Name() string {
+ return path.Join(f.Path...)
+}
+
type Piece struct {
Length int
CheckSum [sha1.Size]byte
@@ -93,13 +97,9 @@ func (i Info) FullPath(n int) (string, error) {
if n >= len(i.Files) || n < 0 {
return "", errors.New("out of range")
}
- p := append([]string{i.Name}, i.Files[n].Path...)
- return path.Join(p...), nil
+ return path.Join(i.Name, i.Files[n].Name()), nil
}
-// piece-to-file mapping:
-// piece # -> [ { file #, off, len }, ... ]
-
func (i Info) Offset(piece int) int {
return i.PieceLength * piece
}