當前位置: 首頁>>代碼示例>>Golang>>正文


Golang ReadResponse.Data方法代碼示例

本文整理匯總了Golang中camlistore/org/third_party/code/google/com/p/rsc/fuse.ReadResponse.Data方法的典型用法代碼示例。如果您正苦於以下問題:Golang ReadResponse.Data方法的具體用法?Golang ReadResponse.Data怎麽用?Golang ReadResponse.Data使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在camlistore/org/third_party/code/google/com/p/rsc/fuse.ReadResponse的用法示例。


在下文中一共展示了ReadResponse.Data方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: Read

func (s staticFileNode) Read(req *fuse.ReadRequest, res *fuse.ReadResponse, intr fuse.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
}
開發者ID:JayBlaze420,項目名稱:camlistore,代碼行數:13,代碼來源:fs.go

示例2: Read

func (s *stat) Read(req *fuse.ReadRequest, res *fuse.ReadResponse, intr fuse.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
}
開發者ID:rn2dy,項目名稱:camlistore,代碼行數:14,代碼來源:debug.go

示例3: Read

func (h *mutFileHandle) Read(req *fuse.ReadRequest, res *fuse.ReadResponse, intr fuse.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
}
開發者ID:JayBlaze420,項目名稱:camlistore,代碼行數:18,代碼來源:mut.go

示例4: Read

func (nr *nodeReader) Read(req *fuse.ReadRequest, res *fuse.ReadResponse, intr fuse.Intr) fuse.Error {
	log.Printf("CAMLI nodeReader READ on %v: %#v", nr.n.blobref, req)
	if req.Offset >= nr.fr.Size() {
		return nil
	}
	size := req.Size
	if int64(size)+req.Offset >= nr.fr.Size() {
		size -= int((int64(size) + req.Offset) - nr.fr.Size())
	}
	buf := make([]byte, size)
	n, err := nr.fr.ReadAt(buf, req.Offset)
	if err == io.EOF {
		err = nil
	}
	if err != nil {
		log.Printf("camli read on %v at %d: %v", nr.n.blobref, req.Offset, err)
		return fuse.EIO
	}
	res.Data = buf[:n]
	return nil
}
開發者ID:t3rm1n4l,項目名稱:camlistore,代碼行數:21,代碼來源:fs.go

示例5: Read

func (nr *nodeReader) Read(req *fuse.ReadRequest, res *fuse.ReadResponse, intr fuse.Intr) fuse.Error {
	log.Printf("CAMLI nodeReader READ on %v: %#v", nr.n.blobref, req)

	// TODO: this isn't incredibly efficient, creating a new
	// FileReader for each read chunk.  We could do better here
	// and re-use a locked pool of readers, trying to find the one
	// with a current offset <= req.Offset first.
	fr, err := nr.ss.NewFileReader(nr.n.fs.fetcher)
	if err != nil {
		panic(err)
	}
	fr.Skip(uint64(req.Offset))
	buf := make([]byte, req.Size)
	n, err := fr.Read(buf)
	if err != nil && err != io.EOF {
		log.Printf("camli read on %v at %d: %v", nr.n.blobref, req.Offset, err)
		return fuse.EIO
	}
	res.Data = buf[:n]
	return nil
}
開發者ID:splade,項目名稱:camlistore,代碼行數:21,代碼來源:fs.go


注:本文中的camlistore/org/third_party/code/google/com/p/rsc/fuse.ReadResponse.Data方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。