mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-08 10:41:19 +00:00
da20785685
Former-commit-id: 23f542f43b4b493e38f5aa4c29788ed93a63b43b [formerly 71b23a6a28eb045fcfeab6329de69f1e5455486b] Former-commit-id: d12b3a6decc876f010a71f98e11df7387c1aaf2a
21 lines
540 B
Go
21 lines
540 B
Go
package fuseutil // import "bazil.org/fuse/fuseutil"
|
|
|
|
import (
|
|
"bazil.org/fuse"
|
|
)
|
|
|
|
// 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]
|
|
}
|