From 1957094fe49ca580f958509ab1c2697df5f6de38 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Sun, 3 Jan 2016 17:08:18 -0800 Subject: [PATCH 1/2] add type to stat cmd json output License: MIT Signed-off-by: Jeromy --- core/commands/files/files.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/core/commands/files/files.go b/core/commands/files/files.go index f159e56c9..e426088a6 100644 --- a/core/commands/files/files.go +++ b/core/commands/files/files.go @@ -115,11 +115,22 @@ func statNode(ds dag.DAGService, fsn mfs.FSNode) (*Object, error) { return nil, err } + var ndtype string + switch fsn.Type() { + case mfs.TDir: + ndtype = "directory" + case mfs.TFile: + ndtype = "file" + default: + return nil, fmt.Errorf("unrecognized node type: %s", fsn.Type()) + } + return &Object{ Hash: k.B58String(), Blocks: len(nd.Links), Size: d.GetFilesize(), CumulativeSize: cumulsize, + Type: ndtype, }, nil } @@ -187,6 +198,7 @@ type Object struct { Size uint64 CumulativeSize uint64 Blocks int + Type string } type FilesLsOutput struct { From f485fa4b1e37a1c387c101bcf2a963cab0b7dfc2 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Sat, 16 Jan 2016 10:07:05 -0800 Subject: [PATCH 2/2] add type to stat printed output License: MIT Signed-off-by: Jeromy --- core/commands/files/files.go | 1 + 1 file changed, 1 insertion(+) diff --git a/core/commands/files/files.go b/core/commands/files/files.go index e426088a6..ae082e08b 100644 --- a/core/commands/files/files.go +++ b/core/commands/files/files.go @@ -87,6 +87,7 @@ var FilesStatCmd = &cmds.Command{ fmt.Fprintf(buf, "Size: %d\n", out.Size) fmt.Fprintf(buf, "CumulativeSize: %d\n", out.CumulativeSize) fmt.Fprintf(buf, "ChildBlocks: %d\n", out.Blocks) + fmt.Fprintf(buf, "Type: %s\n", out.Type) return buf, nil }, },