本文整理匯總了Golang中camlistore/org/third_party/bazil/org/fuse.ReadResponse類的典型用法代碼示例。如果您正苦於以下問題:Golang ReadResponse類的具體用法?Golang ReadResponse怎麽用?Golang ReadResponse使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了ReadResponse類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: HandleRead
// HandleRead handles a read request assuming that data is the entire file content.
// It adjusts the amount returned in resp according to req.Offset and req.Size.
func HandleRead(req *fuse.ReadRequest, resp *fuse.ReadResponse, data []byte) {
if req.Offset >= int64(len(data)) {
data = nil
} else {
data = data[req.Offset:]
}
if len(data) > req.Size {
data = data[:req.Size]
}
n := copy(resp.Data[:req.Size], data)
resp.Data = resp.Data[:n]
}
示例2: Read
func (s staticFileNode) Read(req *fuse.ReadRequest, res *fuse.ReadResponse, intr fusefs.Intr) fuse.Error {
if req.Offset > int64(len(s)) {
return nil
}
s = s[req.Offset:]
size := req.Size
if size > len(s) {
size = len(s)
}
res.Data = make([]byte, size)
copy(res.Data, s)
return nil
}
示例3: Read
func (s *stat) Read(req *fuse.ReadRequest, res *fuse.ReadResponse, intr fs.Intr) fuse.Error {
c := s.content()
if req.Offset > int64(len(c)) {
return nil
}
c = c[req.Offset:]
size := req.Size
if size > len(c) {
size = len(c)
}
res.Data = make([]byte, size)
copy(res.Data, c)
return nil
}
示例4: Read
func (h *mutFileHandle) Read(req *fuse.ReadRequest, res *fuse.ReadResponse, intr fs.Intr) fuse.Error {
if h.tmp == nil {
log.Printf("Read called on camli mutFileHandle without a tempfile set")
return fuse.EIO
}
buf := make([]byte, req.Size)
n, err := h.tmp.ReadAt(buf, req.Offset)
if err == io.EOF {
err = nil
}
if err != nil {
log.Printf("mutFileHandle.Read: %v", err)
return fuse.EIO
}
res.Data = buf[:n]
return nil
}
示例5: Read
func (benchFile) Read(req *fuse.ReadRequest, resp *fuse.ReadResponse, intr fs.Intr) fuse.Error {
resp.Data = resp.Data[:cap(resp.Data)]
return nil
}