| 1 | package fsutil |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | "hash" |
| 6 | "os" |
| 7 | |
| 8 | "github.com/pkg/errors" |
| 9 | "github.com/tonistiigi/fsutil/types" |
| 10 | ) |
| 11 | |
| 12 | type walkerFn func(ctx context.Context, pathC chan<- *currentPath) error |
| 13 | |
| 14 | func Changes(ctx context.Context, a, b walkerFn, changeFn ChangeFunc) error { |
| 15 | return nil |
| 16 | } |
| 17 | |
| 18 | type HandleChangeFn func(ChangeKind, string, os.FileInfo, error) error |
| 19 | |
| 20 | type ContentHasher func(*types.Stat) (hash.Hash, error) |
| 21 | |
| 22 | func getWalkerFn(root string) walkerFn { |
| 23 | return func(ctx context.Context, pathC chan<- *currentPath) error { |
| 24 | return errors.Wrap(Walk(ctx, root, nil, func(path string, f os.FileInfo, err error) error { |
| 25 | if err != nil { |
| 26 | return err |
| 27 | } |
| 28 | |
| 29 | stat, ok := f.Sys().(*types.Stat) |
| 30 | if !ok { |
| 31 | return errors.Errorf("%T invalid file without stat information", f.Sys()) |
| 32 | } |
| 33 | |
| 34 | p := ¤tPath{ |
| 35 | path: path, |
| 36 | stat: stat, |
| 37 | } |
| 38 | |
| 39 | select { |
| 40 | case <-ctx.Done(): |
| 41 | return ctx.Err() |
| 42 | case pathC <- p: |
| 43 | return nil |
| 44 | } |
| 45 | }), "failed to walk") |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | func emptyWalker(ctx context.Context, pathC chan<- *currentPath) error { |
| 50 | return nil |
| 51 | } |