ufile

package
v0.5.14 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2019 License: GPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Res

type Res struct {
	RawPath  string        // 用户输入的原始路径
	Path     string        // 实际使用的路径(绝对路径)
	Userdata UserData      // 用户数据
	Rc       io.ReadCloser // 文件 ,出错时为空
	Err      error         // 是否出现了错误
}

type UFile

type UFile struct {
	ResChan chan (*Res) // 结果信道,加载器关闭时信道也会关闭。
	// contains filtered or unexported fields
}

func NewUFile

func NewUFile(basePath string, checkInterval time.Duration) (*UFile, error)

NewUFile 新建文件加载器 basePath 本地文件的基本路径 checkInterval 网络文件的最小检测间隔

func (*UFile) Add

func (u *UFile) Add(path string, updateInterval time.Duration, userdata UserData) error

添加文件(允许本地路径及远程路径) 即使本地文件不存在只要目录存在就会安全返回,通过信道返回文件不存在的提示。等文件创建时会再次通过信道返回正确的内容。 url 只要格式正确就会返回,之后会启动新协程下载文件,成功失败都会通过信道返回结果。 注意:添加本地文件时文件所在的目录必须存在,不存在会尝试创建,创建失败会添加失败,返回错误。

func (*UFile) Close

func (u *UFile) Close()

关闭文件加载器 同时会关闭 ResChan 。

func (*UFile) Remove

func (u *UFile) Remove(path string) error

移除文件 移除文件变更监听。

type UserData

type UserData interface{}

Jump to

Keyboard shortcuts

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