6 "github.com/anacrolix/torrent/metainfo"
9 // Provides access to regions of torrent data that correspond to its files.
18 // Data for this file begins this far into the torrent.
19 func (f *File) Offset() int64 {
23 func (f File) FileInfo() metainfo.FileInfo {
27 func (f File) Path() string {
31 func (f *File) Length() int64 {
35 // The relative file path for a multi-file torrent, and the torrent name for a
36 // single-file torrent.
37 func (f *File) DisplayPath() string {
38 fip := f.FileInfo().Path
40 return f.t.Info().Name
42 return strings.Join(fip, "/")
46 type FilePieceState struct {
47 Bytes int64 // Bytes within the piece that are part of this File.
51 // Returns the state of pieces in this file.
52 func (f *File) State() (ret []FilePieceState) {
53 pieceSize := int64(f.t.usualPieceSize())
54 off := f.offset % pieceSize
56 for i := int(f.offset / pieceSize); ; i++ {
60 len1 := pieceSize - off
65 ps := f.t.pieceState(i)
67 ret = append(ret, FilePieceState{len1, ps})
74 func (f *File) PrioritizeRegion(off, len int64) {
75 if off < 0 || off >= f.length {
78 if off+len > f.length {
82 f.t.SetRegionPriority(off, len)