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) {
38 pieceSize := int64(f.t.usualPieceSize())
39 off := f.offset % pieceSize
41 for i := int(f.offset / pieceSize); ; i++ {
45 len1 := pieceSize - off
50 ps := f.t.pieceState(i)
52 ret = append(ret, FilePieceState{len1, ps})
59 func (f *File) PrioritizeRegion(off, len int64) {
60 if off < 0 || off >= f.length {
63 if off+len > f.length {
67 f.t.SetRegionPriority(off, len)