3 import "github.com/anacrolix/torrent/metainfo"
5 // Provides access to regions of torrent data that correspond to its files.
14 // Data for this file begins this far into the torrent.
15 func (f *File) Offset() int64 {
19 func (f File) FileInfo() metainfo.FileInfo {
23 func (f File) Path() string {
27 func (f *File) Length() int64 {
31 type FilePieceState struct {
32 Bytes int64 // Bytes within the piece that are part of this File.
36 // Returns the state of pieces in this file.
37 func (f *File) State() (ret []FilePieceState) {
39 defer f.t.cl.mu.Unlock()
40 pieceSize := int64(f.t.usualPieceSize())
41 off := f.offset % pieceSize
43 for i := int(f.offset / pieceSize); ; i++ {
47 len1 := pieceSize - off
51 ret = append(ret, FilePieceState{len1, f.t.pieceState(i)})
58 func (f *File) PrioritizeRegion(off, len int64) {
59 if off < 0 || off >= f.length {
62 if off+len > f.length {
66 f.t.SetRegionPriority(off, len)