2
0
mirror of synced 2025-02-24 14:48:27 +00:00
torrent/fs/filenode.go

30 lines
549 B
Go
Raw Normal View History

package torrentfs
import (
"bazil.org/fuse"
fusefs "bazil.org/fuse/fs"
"golang.org/x/net/context"
2018-01-09 23:12:01 +11:00
"github.com/anacrolix/torrent"
)
type fileNode struct {
node
2018-01-06 16:37:13 +11:00
f *torrent.File
}
var (
_ fusefs.NodeOpener = fileNode{}
)
func (fn fileNode) Attr(ctx context.Context, attr *fuse.Attr) error {
2018-01-06 16:37:13 +11:00
attr.Size = uint64(fn.f.Length())
attr.Mode = defaultMode
return nil
}
func (fn fileNode) Open(ctx context.Context, req *fuse.OpenRequest, resp *fuse.OpenResponse) (fusefs.Handle, error) {
2018-01-06 16:37:13 +11:00
r := fn.f.NewReader()
return fileHandle{fn, r}, nil
}