@@ -32,7 +32,7 @@ func ListCar(c *cli.Context) error {
32
32
}
33
33
defer outStream .Close ()
34
34
35
- if c .Bool ("unixfs" ) {
35
+ if c .Bool ("unixfs" ) || c . Bool ( "unixfs-blocks" ) {
36
36
return listUnixfs (c , outStream )
37
37
}
38
38
@@ -180,7 +180,12 @@ func printUnixFSNode(c *cli.Context, prefix string, node cid.Cid, ls *ipld.LinkS
180
180
for ! i .Done () {
181
181
_ , l := i .Next ()
182
182
name := path .Join (prefix , l .Name .Must ().String ())
183
- fmt .Fprintf (outStream , "%s\n " , name )
183
+ if c .Bool ("unixfs-blocks" ) {
184
+ cidL , _ := l .Hash .AsLink ()
185
+ fmt .Fprintf (outStream , "%s %s\n " , cidL .(cidlink.Link ).Cid , name )
186
+ } else {
187
+ fmt .Fprintf (outStream , "%s\n " , name )
188
+ }
184
189
// recurse into the file/directory
185
190
cl , err := l .Hash .AsLink ()
186
191
if err != nil {
@@ -201,7 +206,12 @@ func printUnixFSNode(c *cli.Context, prefix string, node cid.Cid, ls *ipld.LinkS
201
206
i := hn .Iterator ()
202
207
for ! i .Done () {
203
208
n , l := i .Next ()
204
- fmt .Fprintf (outStream , "%s\n " , path .Join (prefix , n .String ()))
209
+ if c .Bool ("unixfs-blocks" ) {
210
+ cl , _ := l .AsLink ()
211
+ fmt .Fprintf (outStream , "%s %s\n " , cl .(cidlink.Link ).Cid , path .Join (prefix , n .String ()))
212
+ } else {
213
+ fmt .Fprintf (outStream , "%s\n " , path .Join (prefix , n .String ()))
214
+ }
205
215
// recurse into the file/directory
206
216
cl , err := l .AsLink ()
207
217
if err != nil {
0 commit comments