@cryptotaxi247 / kubo / commits / 1957094fe

add type to stat cmd json output

License: MIT Signed-off-by: Jeromy <jeromyj@gmail.com>

Jeromy committed Jan 3, 2016 at 17:08 UTC 1957094fe49ca580f958509ab1c2697df5f6de38
1 file changed +12
core/commands/files/files.go
+12
@@ -115,11 +115,22 @@ func statNode(ds dag.DAGService, fsn mfs.FSNode) (*Object, error) {
115 return nil, err
116 }
117
118 + var ndtype string
119 + switch fsn.Type() {
120 + case mfs.TDir:
121 + ndtype = "directory"
122 + case mfs.TFile:
123 + ndtype = "file"
124 + default:
125 + return nil, fmt.Errorf("unrecognized node type: %s", fsn.Type())
126 + }
127 +
128 return &Object{
129 Hash: k.B58String(),
130 Blocks: len(nd.Links),
131 Size: d.GetFilesize(),
132 CumulativeSize: cumulsize,
133 + Type: ndtype,
134 }, nil
135 }
136
@@ -187,6 +198,7 @@ type Object struct {
198 Size uint64
199 CumulativeSize uint64
200 Blocks int
201 + Type string
202 }
203
204 type FilesLsOutput struct {