示例#1
0
文件: vtmm.go 项目: mischief/govt
func (srv *Vtmap) Read(req *vtsrv.Req) {
	srv.Lock()
	strscore := string([]byte(req.Tc.Score))
	b := srv.htbl[strscore]
	srv.Unlock()

	if b == nil {
		req.RespondError("not found")
	} else {
		req.RespondRead(b)
	}
}
示例#2
0
文件: vtram.go 项目: mischief/govt
func (srv *Vtram) Read(req *vtsrv.Req) {
	b := srv.getBlock(req.Tc.Score)
	if b == nil {
		req.RespondError("not found")
	} else {
		n := int(req.Tc.Count)
		if n > len(b.data) {
			n = len(b.data)
		}

		req.RespondRead(b.data[0:n])
	}
}
示例#3
0
文件: grande.go 项目: mischief/govt
func (srv *Grande) Read(req *vtsrv.Req) {
	var n int

	bname := srv.Name(req.Tc.Score)
	f, err := os.Open(bname)
	if err != nil {
		req.RespondError(err.Error())
		return
	}

	b := make([]byte, req.Tc.Count)
	n, err = f.Read(b)
	f.Close()
	if err != nil {
		req.RespondError(err.Error())
		return
	}

	req.RespondRead(b[0:n])
}