// ReadAll reads the object data as file data func (s *Node) ReadAll(intr fs.Intr) ([]byte, fuse.Error) { u.DOut("Read node.\n") r, err := mdag.NewDagReader(s.Nd, s.Ipfs.DAG) if err != nil { return nil, err } // this is a terrible function... 'ReadAll'? // what if i have a 6TB file? GG RAM. return ioutil.ReadAll(r) }
func Cat(n *core.IpfsNode, args []string, opts map[string]interface{}, out io.Writer) error { for _, fn := range args { dagnode, err := n.Resolver.ResolvePath(fn) if err != nil { return fmt.Errorf("catFile error: %v", err) } read, err := mdag.NewDagReader(dagnode, n.DAG) if err != nil { return fmt.Errorf("cat error: %v", err) } _, err = io.Copy(out, read) if err != nil { return fmt.Errorf("cat error: %v", err) } } return nil }
func testFileConsistency(t *testing.T, bs BlockSplitter, nbytes int) { buf := new(bytes.Buffer) io.CopyN(buf, rand.Reader, int64(nbytes)) should := buf.Bytes() nd, err := NewDagFromReaderWithSplitter(buf, bs) if err != nil { t.Fatal(err) } r, err := dag.NewDagReader(nd, nil) if err != nil { t.Fatal(err) } out, err := ioutil.ReadAll(r) if err != nil { t.Fatal(err) } err = arrComp(out, should) if err != nil { t.Fatal(err) } }