Example #1
0
func (me *mmapTorrentStorage) Piece(p metainfo.Piece) Piece {
	return mmapStoragePiece{
		storage:  me,
		p:        p,
		ReaderAt: io.NewSectionReader(me.span, p.Offset(), p.Length()),
		WriterAt: missinggo.NewSectionWriter(me.span, p.Offset(), p.Length()),
	}
}
Example #2
0
func (fts *fileTorrentStorage) Piece(p metainfo.Piece) Piece {
	// Create a view onto the file-based torrent storage.
	_io := fileStorageTorrent{fts}
	// Return the appropriate segments of this.
	return &fileStoragePiece{
		fts,
		p,
		missinggo.NewSectionWriter(_io, p.Offset(), p.Length()),
		io.NewSectionReader(_io, p.Offset(), p.Length()),
	}
}
Example #3
0
func (me *fileStorage) Piece(p metainfo.Piece) Piece {
	_io := &fileStorageTorrent{
		p.Info,
		me.baseDir,
	}
	return &fileStoragePiece{
		me,
		p,
		missinggo.NewSectionWriter(_io, p.Offset(), p.Length()),
		io.NewSectionReader(_io, p.Offset(), p.Length()),
	}
}