OSDN Git Service

add ipfs package
[bytom/vapor.git] / vendor / github.com / ipfs / go-ipfs-api / unixfs.go
1 package shell
2
3 import (
4         "context"
5         "fmt"
6 )
7
8 type UnixLsObject struct {
9         Hash  string
10         Size  uint64
11         Type  string
12         Links []*UnixLsLink
13 }
14
15 type UnixLsLink struct {
16         Hash string
17         Name string
18         Size uint64
19         Type string
20 }
21
22 type lsOutput struct {
23         Objects map[string]*UnixLsObject
24 }
25
26 // FileList entries at the given path using the UnixFS commands
27 func (s *Shell) FileList(path string) (*UnixLsObject, error) {
28         var out lsOutput
29         if err := s.Request("file/ls", path).Exec(context.Background(), &out); err != nil {
30                 return nil, err
31         }
32
33         for _, object := range out.Objects {
34                 return object, nil
35         }
36
37         return nil, fmt.Errorf("no object in results")
38 }