filesection

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2020 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileSection

type FileSection struct {
	File   ReadWriterAt
	Offset int64
	Length int64
	Name   string
}

FileSection of a file.

type Piece

type Piece []FileSection

Piece is contiguous sections of files. When piece hashes in torrent file is being calculated all files are concatenated and splitted into pieces in length specified in the torrent file.

func (Piece) ReadAt

func (p Piece) ReadAt(b []byte, off int64) (int, error)

ReadAt implements io.ReaderAt interface. It reads bytes from s at given offset into p. Used when uploading blocks of a piece.

func (Piece) Write

func (p Piece) Write(b []byte) (n int, err error)

Write implements io.Writer interface. It writes the bytes in p into files in s. Used when writing a downloaded piece (all blocks) after hash check is done. Calling write does not change the current position in s, so len(p) must be equal to total length of the all files in s in order to issue a full write.

type ReadWriterAt

type ReadWriterAt interface {
	io.ReaderAt
	io.WriterAt
}

ReadWriterAt combines the io.ReaderAt and io.WriterAt interfaces.

Jump to

Keyboard shortcuts

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