}
func (f *File) NewReader() Reader {
- tr := reader{
- mu: f.t.cl.locker(),
- t: f.t,
- readahead: 5 * 1024 * 1024,
- offset: f.Offset(),
- length: f.Length(),
- }
- f.t.addReader(&tr)
- return &tr
+ return f.t.newReader(f.Offset(), f.Length())
}
// Sets the minimum priority for pieces in the File.
// Returns a Reader bound to the torrent's data. All read calls block until the data requested is
// actually available. Note that you probably want to ensure the Torrent Info is available first.
func (t *Torrent) NewReader() Reader {
+ return t.newReader(0, *t.length)
+}
+
+func (t *Torrent) newReader(offset, length int64) Reader {
r := reader{
mu: t.cl.locker(),
t: t,
readahead: 5 * 1024 * 1024,
- length: *t.length,
+ offset: offset,
+ length: length,
}
t.addReader(&r)
return &r