当前位置: 首页>>代码示例>>Golang>>正文


Golang torrent.File类代码示例

本文整理汇总了Golang中github.com/anacrolix/torrent.File的典型用法代码示例。如果您正苦于以下问题:Golang File类的具体用法?Golang File怎么用?Golang File使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了File类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: Example_fileReader

func Example_fileReader() {
	var (
		t torrent.Torrent
		f torrent.File
	)
	r := t.NewReader()
	defer r.Close()
	// Access the parts of the torrent pertaining to f. Data will be
	// downloaded as required, per the configuration of the torrent.Reader.
	_ = missinggo.NewSectionReadSeeker(r, f.Offset(), f.Length())
}
开发者ID:jpillora,项目名称:torrent,代码行数:11,代码来源:example_test.go

示例2: NewFileReader

// NewFileReader sets up a torrent file for streaming reading.
func NewFileReader(c Client, f *torrent.File) (SeekableContent, error) {
	// We read ahead 1% of the file continuously.
	var readahead = f.Length() / 100

	reader := c.Torrent.NewReader()
	reader.SetReadahead(readahead)
	reader.SetResponsive()
	_, err := reader.Seek(f.Offset(), os.SEEK_SET)

	return &FileEntry{
		File:   f,
		Reader: reader,
	}, err
}
开发者ID:ssi379,项目名称:go-peerflix,代码行数:15,代码来源:fileEntry.go

示例3: NewFileReader

// NewFileReader sets up a torrent file for streaming reading.
func NewFileReader(c Client, f torrent.File) (SeekableContent, error) {
	// We read ahead 1% of the file continuously.
	var readahead = f.Length() / 100

	// We begin by prioritizing 5% of the beginning of the file.
	f.PrioritizeRegion(f.Offset(), readahead*5)

	reader := c.Torrent.NewReader()
	reader.SetReadahead(readahead)
	reader.SetResponsive()
	_, err := reader.Seek(f.Offset(), os.SEEK_SET)

	return &FileEntry{
		File:   &f,
		Reader: reader,
	}, err
}
开发者ID:kelvl,项目名称:go-peerflix,代码行数:18,代码来源:fileEntry.go

示例4: DownloadPlay

func (this *DownloaderService) DownloadPlay(downloader_id, file_path string) (sc SeekAbleContent, path string, err error) {
	log.Println("DownloadPlay: downloader_id -> ", downloader_id, " file_path -> ", file_path)
	this.RLock()
	defer this.RUnlock()

	var downloader = &downloader.Downloader{}
	var file torrent.File

	downloader, err = this.df.Get(downloader_id)
	if err != nil {
		return
	}

	file, err = downloader.GetFileFoPlay(file_path)
	if err != nil {
		return
	}

	sc, err = NewReader(downloader.Torrent, file)
	if err != nil {
		return
	}
	return sc, file.DisplayPath(), nil
}
开发者ID:bmartynov,项目名称:gochromecast,代码行数:24,代码来源:service.go

示例5: NewFileReader

// NewFileReader sets up a torrent file for streaming reading.
func NewFileReader(f *torrent.File) (SeekableContent, error) {
	// Start download
	f.Download()

	torrent := f.Torrent()
	reader := torrent.NewReader()

	// Read ahead 10mb
	reader.SetReadahead(1024 * 1024 * 10)
	reader.SetResponsive()
	_, err := reader.Seek(f.Offset(), os.SEEK_SET)

	return &FileEntry{
		File:   f,
		Reader: reader,
		N:      f.Length(),
	}, err
}
开发者ID:bbirec,项目名称:PeerPlayer,代码行数:19,代码来源:fileEntry.go

示例6: GetTorrentPercent

func (e *Engine) GetTorrentPercent(file *torrent.File) float32 {
	t := e.upsertTorrent(file.Torrent())
	return t.Percent
}
开发者ID:Zarloc,项目名称:cloud-torrent,代码行数:4,代码来源:engine.go


注:本文中的github.com/anacrolix/torrent.File类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。