From ed314439d5acc345e5101d61afb366c55c2921f8 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Tue, 5 Jul 2016 21:26:02 +0200 Subject: wip --- meta/torrent.go | 10 +++++----- 1 file 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 } -- cgit v1.2.3