tfs

package
v1.3.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 31, 2024 License: MPL-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const DownloadExt = ".tordata"

DownloadExt is the extension used for the torrent download data file.

Variables

This section is empty.

Functions

This section is empty.

Types

type EmbeddedFile

type EmbeddedFile struct {
	Name   string
	Dir    string
	Length int64
	// contains filtered or unexported fields
}

EmbeddedFile represents a file embedded in torrent file storage.

func (*EmbeddedFile) Close

func (ef *EmbeddedFile) Close() error

Close the file. May be called more than once.

func (*EmbeddedFile) Open

func (ef *EmbeddedFile) Open() (*io.SectionReader, error)

Open the file for reading.

type File

type File struct {
	Path     string `bencode:"-"`
	Announce string `bencode:"announce"`
	Info     struct {
		Name        string `bencode:"name"`
		PieceLength int    `bencode:"piece length"`
		Pieces      []byte `bencode:"pieces"`
		Length      int64  `bencode:"length,omitempty"`
		Files       []struct {
			Length int64    `bencode:"length"`
			Path   []string `bencode:"path"`
		} `bencode:"files,omitempty"`
		Private bool `bencode:"private"`
	} `bencode:"info"`
	InfoHash InfoHash `bencode:"-"`
	// contains filtered or unexported fields
}

File holds the contents of a .torrent file.

func NewFileFromBytes

func NewFileFromBytes(data []byte) (*File, error)

NewFileFromBytes creates a torrent file structure from the raw torrent file data.

func NewFileFromPath

func NewFileFromPath(path string) (*File, error)

NewFileFromPath creates a torrent file structure from the raw torrent file data.

func NewFileFromReader

func NewFileFromReader(r io.Reader) (*File, error)

NewFileFromReader creates a torrent file structure from the raw torrent file data.

func (*File) EmbeddedFiles

func (f *File) EmbeddedFiles() []os.FileInfo

EmbeddedFiles returns the files embedded in the torrent file. This should only be used after a torrent has completely downloaded.

func (*File) LengthOf

func (f *File) LengthOf(index int) int

LengthOf returns the length of the piece at the specified index.

func (*File) OffsetOf

func (f *File) OffsetOf(index int) int64

OffsetOf returns the offset into the data for the piece at the specified index.

func (*File) Open

func (f *File) Open(name string) (fs.File, error)

Open implements the fs.FS interface.

func (*File) PieceCount

func (f *File) PieceCount() int

PieceCount returns the number of pieces.

func (*File) Size

func (f *File) Size() int64

Size returns the size of the complete data.

func (*File) StoragePath

func (f *File) StoragePath() string

StoragePath returns the path that will be used for torrent file storage.

func (*File) Validate

func (f *File) Validate(index int, buffer []byte) bool

Validate checks the supplied buffer to determine if it contains the data for the piece at the specified index.

type InfoHash

type InfoHash [sha1.Size]byte

InfoHash holds the hash of the torrent info.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL