Example #1
0
func (w *Writes) Write(req *fuse.WriteRequest, resp *fuse.WriteResponse, intr fs.Intr) fuse.Error {
	n, err := w.buf.Write(req.Data)
	resp.Size = n
	if err != nil {
		// TODO hiding error
		return fuse.EIO
	}
	return nil
}
Example #2
0
func (n *Node) Write(req *fuse.WriteRequest, resp *fuse.WriteResponse, intr fs.Intr) fuse.Error {
	log.Debugf("ipns: Node Write [%s]: flags = %s, offset = %d, size = %d", n.name, req.Flags.String(), req.Offset, len(req.Data))

	if n.dagMod == nil {
		// Create a DagModifier to allow us to change the existing dag node
		dmod, err := uio.NewDagModifier(n.Nd, n.Ipfs.DAG, chunk.DefaultSplitter)
		if err != nil {
			log.Errorf("Error creating dag modifier: %s", err)
			return err
		}
		n.dagMod = dmod
	}
	wrote, err := n.dagMod.WriteAt(req.Data, uint64(req.Offset))
	if err != nil {
		return err
	}
	resp.Size = wrote
	return nil
}
Example #3
0
func (f *inMemoryFile) Write(req *fuse.WriteRequest, resp *fuse.WriteResponse, intr fs.Intr) fuse.Error {
	resp.Size = copy(f.data[req.Offset:], req.Data)
	return nil
}
Example #4
0
func (benchFile) Write(req *fuse.WriteRequest, resp *fuse.WriteResponse, intr fs.Intr) fuse.Error {
	resp.Size = len(req.Data)
	return nil
}