ListJSON lists fsrc using the options in opt calling callback for each item
(ctx context.Context, fsrc fs.Fs, remote string, opt *ListJSONOpt, callback func(*ListJSONItem) error)
| 241 | |
| 242 | // ListJSON lists fsrc using the options in opt calling callback for each item |
| 243 | func ListJSON(ctx context.Context, fsrc fs.Fs, remote string, opt *ListJSONOpt, callback func(*ListJSONItem) error) error { |
| 244 | lj, err := newListJSON(ctx, fsrc, remote, opt) |
| 245 | if err != nil { |
| 246 | return err |
| 247 | } |
| 248 | err = walk.ListR(ctx, fsrc, remote, false, ConfigMaxDepth(ctx, lj.opt.Recurse), walk.ListAll, func(entries fs.DirEntries) (err error) { |
| 249 | for _, entry := range entries { |
| 250 | item, err := lj.entry(ctx, entry) |
| 251 | if err != nil { |
| 252 | return fmt.Errorf("creating entry failed in ListJSON: %w", err) |
| 253 | } |
| 254 | if item != nil { |
| 255 | err = callback(item) |
| 256 | if err != nil { |
| 257 | return fmt.Errorf("callback failed in ListJSON: %w", err) |
| 258 | } |
| 259 | } |
| 260 | } |
| 261 | return nil |
| 262 | }) |
| 263 | if err != nil { |
| 264 | return fmt.Errorf("error in ListJSON: %w", err) |
| 265 | } |
| 266 | return nil |
| 267 | } |
| 268 | |
| 269 | // StatJSON returns a single JSON stat entry for the fsrc, remote path |
| 270 | // |
searching dependent graphs…