本文整理汇总了Golang中github.com/jacobsa/fuse/fuseops.ReadDirOp.Context方法的典型用法代码示例。如果您正苦于以下问题:Golang ReadDirOp.Context方法的具体用法?Golang ReadDirOp.Context怎么用?Golang ReadDirOp.Context使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/jacobsa/fuse/fuseops.ReadDirOp
的用法示例。
在下文中一共展示了ReadDirOp.Context方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: ReadDir
// Handle a request to read from the directory, without responding.
//
// Special case: we assume that a zero offset indicates that rewinddir has been
// called (since fuse gives us no way to intercept and know for sure), and
// start the listing process over again.
//
// LOCKS_REQUIRED(dh.Mu)
// LOCKS_EXCLUDED(du.in)
func (dh *dirHandle) ReadDir(
op *fuseops.ReadDirOp) (err error) {
// If the request is for offset zero, we assume that either this is the first
// call or rewinddir has been called. Reset state.
if op.Offset == 0 {
dh.entries = nil
dh.entriesValid = false
}
// Do we need to read entries from GCS?
if !dh.entriesValid {
err = dh.ensureEntries(op.Context())
if err != nil {
return
}
}
// Is the offset past the end of what we have buffered? If so, this must be
// an invalid seekdir according to posix.
index := int(op.Offset)
if index > len(dh.entries) {
err = fuse.EINVAL
return
}
// We copy out entries until we run out of entries or space.
for i := index; i < len(dh.entries); i++ {
op.Data = fuseutil.AppendDirent(op.Data, dh.entries[i])
if len(op.Data) > op.Size {
op.Data = op.Data[:op.Size]
break
}
}
return
}