| 1 | package fsutilscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/ |
| 2 | |
| 3 | import ( |
| 4 | "contextscip-go gomod github.com/golang/go/src go1.21 context/" |
| 5 | "ioscip-go gomod github.com/golang/go/src go1.21 io/" |
| 6 | gofsscip-go gomod github.com/golang/go/src go1.21 `io/fs`/ "io/fsscip-go gomod github.com/golang/go/src go1.21 `io/fs`/" |
| 7 | "osscip-go gomod github.com/golang/go/src go1.21 os/" |
| 8 | "pathscip-go gomod github.com/golang/go/src go1.21 path/" |
| 9 | "path/filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/" |
| 10 | "sortscip-go gomod github.com/golang/go/src go1.21 sort/" |
| 11 | "stringsscip-go gomod github.com/golang/go/src go1.21 strings/" |
| 12 | "syscallscip-go gomod github.com/golang/go/src go1.21 syscall/" |
| 13 | "timescip-go gomod github.com/golang/go/src go1.21 time/" |
| 14 | |
| 15 | "github.com/pkg/errorsscip-go gomod github.com/pkg/errors v0.9.1 `github.com/pkg/errors`/" |
| 16 | "github.com/tonistiigi/fsutil/typesscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/" |
| 17 | ) |
| 18 | |
| 19 | type FSscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/FS# interface { |
| 20 | Walkscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/FS#Walk.(contextscip-go gomod github.com/golang/go/src go1.21 context/.Contextscip-go gomod github.com/golang/go/src go1.21 context/Context#, string, gofsscip-go gomod github.com/golang/go/src go1.21 `io/fs`/.WalkDirFuncscip-go gomod github.com/golang/go/src go1.21 `io/fs`/WalkDirFunc#) error |
| 21 | Openscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/FS#Open.(string) (ioscip-go gomod github.com/golang/go/src go1.21 io/.ReadCloserscip-go gomod github.com/golang/go/src go1.21 io/ReadCloser#, error) |
| 22 | } |
| 23 | |
| 24 | // NewFS creates a new FS from a root directory on the host filesystem. |
| 25 | func NewFSscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/NewFS().(root string) (FSscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/FS#, error) { |
| 26 | root, err := filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.EvalSymlinksscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/EvalSymlinks().(root) |
| 27 | if err != nil { |
| 28 | return nil, errorsscip-go gomod github.com/pkg/errors v0.9.1 `github.com/pkg/errors`/.WithStackscip-go gomod github.com/pkg/errors v0.9.1 `github.com/pkg/errors`/WithStack().(&osscip-go gomod github.com/golang/go/src go1.21 os/.PathErrorscip-go gomod github.com/golang/go/src go1.21 os/PathError#{Opscip-go gomod github.com/golang/go/src go1.21 `io/fs`/PathError#Op.: "resolve", Pathscip-go gomod github.com/golang/go/src go1.21 `io/fs`/PathError#Path.: root, Errscip-go gomod github.com/golang/go/src go1.21 `io/fs`/PathError#Err.: err}) |
| 29 | } |
| 30 | fi, err := osscip-go gomod github.com/golang/go/src go1.21 os/.Statscip-go gomod github.com/golang/go/src go1.21 os/Stat().(root) |
| 31 | if err != nil { |
| 32 | return nil, err |
| 33 | } |
| 34 | if !fi.IsDirscip-go gomod github.com/golang/go/src go1.21 `io/fs`/FileInfo#IsDir().() { |
| 35 | return nil, errorsscip-go gomod github.com/pkg/errors v0.9.1 `github.com/pkg/errors`/.WithStackscip-go gomod github.com/pkg/errors v0.9.1 `github.com/pkg/errors`/WithStack().(&osscip-go gomod github.com/golang/go/src go1.21 os/.PathErrorscip-go gomod github.com/golang/go/src go1.21 os/PathError#{Opscip-go gomod github.com/golang/go/src go1.21 `io/fs`/PathError#Op.: "stat", Pathscip-go gomod github.com/golang/go/src go1.21 `io/fs`/PathError#Path.: root, Errscip-go gomod github.com/golang/go/src go1.21 `io/fs`/PathError#Err.: syscallscip-go gomod github.com/golang/go/src go1.21 syscall/.ENOTDIRscip-go gomod github.com/golang/go/src go1.21 syscall/ENOTDIR.}) |
| 36 | } |
| 37 | |
| 38 | return &fsscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/fs#{ |
| 39 | rootscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/fs#root.: root, |
| 40 | }, nil |
| 41 | } |
| 42 | |
| 43 | type fsscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/fs# struct { |
| 44 | rootscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/fs#root. string |
| 45 | } |
| 46 | |
| 47 | func (fs *fsscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/fs#) Walkscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/fs#Walk().(ctx contextscip-go gomod github.com/golang/go/src go1.21 context/.Contextscip-go gomod github.com/golang/go/src go1.21 context/Context#, target string, fn gofsscip-go gomod github.com/golang/go/src go1.21 `io/fs`/.WalkDirFuncscip-go gomod github.com/golang/go/src go1.21 `io/fs`/WalkDirFunc#) error { |
| 48 | seenFiles := make(map[uint64]string) |
| 49 | return filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.WalkDirscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/WalkDir().(filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Join().(fs.rootscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/fs#root., target), func(path string, dirEntry gofsscip-go gomod github.com/golang/go/src go1.21 `io/fs`/.DirEntryscip-go gomod github.com/golang/go/src go1.21 `io/fs`/DirEntry#, walkErr error) (retErr error) { |
| 50 | defer func() { |
| 51 | if retErr != nil && isNotExistscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/isNotExist().(retErr) { |
| 52 | retErr = filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.SkipDirscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/SkipDir. |
| 53 | } |
| 54 | }() |
| 55 | |
| 56 | origpath := path |
| 57 | path, err := filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Relscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Rel().(fs.rootscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/fs#root., path) |
| 58 | if err != nil { |
| 59 | return err |
| 60 | } |
| 61 | // Skip root |
| 62 | if path == "." { |
| 63 | return nil |
| 64 | } |
| 65 | |
| 66 | var entry gofsscip-go gomod github.com/golang/go/src go1.21 `io/fs`/.DirEntryscip-go gomod github.com/golang/go/src go1.21 `io/fs`/DirEntry# |
| 67 | if dirEntry != nil { |
| 68 | entry = &DirEntryInfoscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/DirEntryInfo#{ |
| 69 | pathscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/DirEntryInfo#path.: path, |
| 70 | origpathscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/DirEntryInfo#origpath.: origpath, |
| 71 | entryscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/DirEntryInfo#entry.: dirEntry, |
| 72 | seenFilesscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/DirEntryInfo#seenFiles.: seenFiles, |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | select { |
| 77 | case <-ctx.Donescip-go gomod github.com/golang/go/src go1.21 context/Context#Done().(): |
| 78 | return ctx.Errscip-go gomod github.com/golang/go/src go1.21 context/Context#Err().() |
| 79 | default: |
| 80 | if err := fn(path, entry, walkErr); err != nil { |
| 81 | return err |
| 82 | } |
| 83 | } |
| 84 | return nil |
| 85 | }) |
| 86 | } |
| 87 | |
| 88 | func (fs *fsscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/fs#) Openscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/fs#Open().(p string) (ioscip-go gomod github.com/golang/go/src go1.21 io/.ReadCloserscip-go gomod github.com/golang/go/src go1.21 io/ReadCloser#, error) { |
| 89 | rc, err := osscip-go gomod github.com/golang/go/src go1.21 os/.Openscip-go gomod github.com/golang/go/src go1.21 os/Open().(filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Join().(fs.rootscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/fs#root., p)) |
| 90 | return rc, errorsscip-go gomod github.com/pkg/errors v0.9.1 `github.com/pkg/errors`/.WithStackscip-go gomod github.com/pkg/errors v0.9.1 `github.com/pkg/errors`/WithStack().(err) |
| 91 | } |
| 92 | |
| 93 | type Dirscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/Dir# struct { |
| 94 | Statscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/Dir#Stat. *typesscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/.Statscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/Stat# |
| 95 | FSscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/Dir#FS. FSscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/FS# |
| 96 | } |
| 97 | |
| 98 | func SubDirFSscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/SubDirFS().(dirs []Dirscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/Dir#) (FSscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/FS#, error) { |
| 99 | sortscip-go gomod github.com/golang/go/src go1.21 sort/.Slicescip-go gomod github.com/golang/go/src go1.21 sort/Slice().(dirs, func(i, j int) bool { |
| 100 | return dirs[i].Statscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/Dir#Stat..Pathscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/Stat#Path. < dirs[j].Statscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/Dir#Stat..Pathscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/Stat#Path. |
| 101 | }) |
| 102 | m := map[string]Dirscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/Dir#{} |
| 103 | for _, d := range dirs { |
| 104 | if pathscip-go gomod github.com/golang/go/src go1.21 path/.Basescip-go gomod github.com/golang/go/src go1.21 path/Base().(d.Statscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/Dir#Stat..Pathscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/Stat#Path.) != d.Statscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/Dir#Stat..Pathscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/Stat#Path. { |
| 105 | return nil, errorsscip-go gomod github.com/pkg/errors v0.9.1 `github.com/pkg/errors`/.WithStackscip-go gomod github.com/pkg/errors v0.9.1 `github.com/pkg/errors`/WithStack().(&osscip-go gomod github.com/golang/go/src go1.21 os/.PathErrorscip-go gomod github.com/golang/go/src go1.21 os/PathError#{Pathscip-go gomod github.com/golang/go/src go1.21 `io/fs`/PathError#Path.: d.Statscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/Dir#Stat..Pathscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/Stat#Path., Errscip-go gomod github.com/golang/go/src go1.21 `io/fs`/PathError#Err.: syscallscip-go gomod github.com/golang/go/src go1.21 syscall/.EISDIRscip-go gomod github.com/golang/go/src go1.21 syscall/EISDIR., Opscip-go gomod github.com/golang/go/src go1.21 `io/fs`/PathError#Op.: "invalid path"}) |
| 106 | } |
| 107 | if _, ok := m[d.Statscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/Dir#Stat..Pathscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/Stat#Path.]; ok { |
| 108 | return nil, errorsscip-go gomod github.com/pkg/errors v0.9.1 `github.com/pkg/errors`/.WithStackscip-go gomod github.com/pkg/errors v0.9.1 `github.com/pkg/errors`/WithStack().(&osscip-go gomod github.com/golang/go/src go1.21 os/.PathErrorscip-go gomod github.com/golang/go/src go1.21 os/PathError#{Pathscip-go gomod github.com/golang/go/src go1.21 `io/fs`/PathError#Path.: d.Statscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/Dir#Stat..Pathscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/Stat#Path., Errscip-go gomod github.com/golang/go/src go1.21 `io/fs`/PathError#Err.: syscallscip-go gomod github.com/golang/go/src go1.21 syscall/.EEXISTscip-go gomod github.com/golang/go/src go1.21 syscall/EEXIST., Opscip-go gomod github.com/golang/go/src go1.21 `io/fs`/PathError#Op.: "duplicate path"}) |
| 109 | } |
| 110 | m[d.Statscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/Dir#Stat..Pathscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/Stat#Path.] = d |
| 111 | } |
| 112 | return &subDirFSscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/subDirFS#{mscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/subDirFS#m.: m, dirsscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/subDirFS#dirs.: dirs}, nil |
| 113 | } |
| 114 | |
| 115 | type subDirFSscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/subDirFS# struct { |
| 116 | mscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/subDirFS#m. map[string]Dirscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/Dir# |
| 117 | dirsscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/subDirFS#dirs. []Dirscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/Dir# |
| 118 | } |
| 119 | |
| 120 | func (fs *subDirFSscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/subDirFS#) Walkscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/subDirFS#Walk().(ctx contextscip-go gomod github.com/golang/go/src go1.21 context/.Contextscip-go gomod github.com/golang/go/src go1.21 context/Context#, target string, fn gofsscip-go gomod github.com/golang/go/src go1.21 `io/fs`/.WalkDirFuncscip-go gomod github.com/golang/go/src go1.21 `io/fs`/WalkDirFunc#) error { |
| 121 | first, rest, _ := stringsscip-go gomod github.com/golang/go/src go1.21 strings/.Cutscip-go gomod github.com/golang/go/src go1.21 strings/Cut().(target, string(filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Separatorscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Separator.)) |
| 122 | |
| 123 | for _, d := range fs.dirsscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/subDirFS#dirs. { |
| 124 | if first != "" && first != d.Statscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/Dir#Stat..Pathscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/Stat#Path. { |
| 125 | continue |
| 126 | } |
| 127 | |
| 128 | fi := &StatInfoscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/StatInfo#{d.Statscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/Dir#Stat..Clonescip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/Stat#Clone().()} |
| 129 | if !fi.IsDirscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/StatInfo#IsDir().() { |
| 130 | return errorsscip-go gomod github.com/pkg/errors v0.9.1 `github.com/pkg/errors`/.WithStackscip-go gomod github.com/pkg/errors v0.9.1 `github.com/pkg/errors`/WithStack().(&osscip-go gomod github.com/golang/go/src go1.21 os/.PathErrorscip-go gomod github.com/golang/go/src go1.21 os/PathError#{Pathscip-go gomod github.com/golang/go/src go1.21 `io/fs`/PathError#Path.: d.Statscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/Dir#Stat..Pathscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/Stat#Path., Errscip-go gomod github.com/golang/go/src go1.21 `io/fs`/PathError#Err.: syscallscip-go gomod github.com/golang/go/src go1.21 syscall/.ENOTDIRscip-go gomod github.com/golang/go/src go1.21 syscall/ENOTDIR., Opscip-go gomod github.com/golang/go/src go1.21 `io/fs`/PathError#Op.: "walk subdir"}) |
| 131 | } |
| 132 | dStat := d.Statscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/Dir#Stat..Clonescip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/Stat#Clone().() |
| 133 | if err := fn(d.Statscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/Dir#Stat..Pathscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/Stat#Path., &DirEntryInfoscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/DirEntryInfo#{Statscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/DirEntryInfo#Stat.: dStat}, nil); err != nil { |
| 134 | return err |
| 135 | } |
| 136 | if err := d.FSscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/Dir#FS..Walkscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/FS#Walk.(ctx, rest, func(p string, entry gofsscip-go gomod github.com/golang/go/src go1.21 `io/fs`/.DirEntryscip-go gomod github.com/golang/go/src go1.21 `io/fs`/DirEntry#, err error) error { |
| 137 | if err != nil { |
| 138 | return err |
| 139 | } |
| 140 | |
| 141 | fi, err := entry.Infoscip-go gomod github.com/golang/go/src go1.21 `io/fs`/DirEntry#Info().() |
| 142 | if err != nil { |
| 143 | return err |
| 144 | } |
| 145 | stat, ok := fi.Sysscip-go gomod github.com/golang/go/src go1.21 `io/fs`/FileInfo#Sys().().(*typesscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/.Statscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/Stat#) |
| 146 | if !ok { |
| 147 | return errorsscip-go gomod github.com/pkg/errors v0.9.1 `github.com/pkg/errors`/.WithStackscip-go gomod github.com/pkg/errors v0.9.1 `github.com/pkg/errors`/WithStack().(&osscip-go gomod github.com/golang/go/src go1.21 os/.PathErrorscip-go gomod github.com/golang/go/src go1.21 os/PathError#{Pathscip-go gomod github.com/golang/go/src go1.21 `io/fs`/PathError#Path.: d.Statscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/Dir#Stat..Pathscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/Stat#Path., Errscip-go gomod github.com/golang/go/src go1.21 `io/fs`/PathError#Err.: syscallscip-go gomod github.com/golang/go/src go1.21 syscall/.EBADMSGscip-go gomod github.com/golang/go/src go1.21 syscall/EBADMSG., Opscip-go gomod github.com/golang/go/src go1.21 `io/fs`/PathError#Op.: "fileinfo without stat info"}) |
| 148 | } |
| 149 | stat.Pathscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/Stat#Path. = pathscip-go gomod github.com/golang/go/src go1.21 path/.Joinscip-go gomod github.com/golang/go/src go1.21 path/Join().(d.Statscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/Dir#Stat..Pathscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/Stat#Path., stat.Pathscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/Stat#Path.) |
| 150 | if stat.Linknamescip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/Stat#Linkname. != "" { |
| 151 | if fi.Modescip-go gomod github.com/golang/go/src go1.21 `io/fs`/FileInfo#Mode().()&osscip-go gomod github.com/golang/go/src go1.21 os/.ModeSymlinkscip-go gomod github.com/golang/go/src go1.21 os/ModeSymlink. != 0 { |
| 152 | if stringsscip-go gomod github.com/golang/go/src go1.21 strings/.HasPrefixscip-go gomod github.com/golang/go/src go1.21 strings/HasPrefix().(stat.Linknamescip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/Stat#Linkname., "/") { |
| 153 | stat.Linknamescip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/Stat#Linkname. = pathscip-go gomod github.com/golang/go/src go1.21 path/.Joinscip-go gomod github.com/golang/go/src go1.21 path/Join().("/"+d.Statscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/Dir#Stat..Pathscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/Stat#Path., stat.Linknamescip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/Stat#Linkname.) |
| 154 | } |
| 155 | } else { |
| 156 | stat.Linknamescip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/Stat#Linkname. = pathscip-go gomod github.com/golang/go/src go1.21 path/.Joinscip-go gomod github.com/golang/go/src go1.21 path/Join().(d.Statscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/Dir#Stat..Pathscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/Stat#Path., stat.Linknamescip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/Stat#Linkname.) |
| 157 | } |
| 158 | } |
| 159 | return fn(filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Join().(d.Statscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/Dir#Stat..Pathscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/Stat#Path., p), &DirEntryInfoscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/DirEntryInfo#{Statscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/DirEntryInfo#Stat.: stat}, nil) |
| 160 | }); err != nil { |
| 161 | return err |
| 162 | } |
| 163 | } |
| 164 | return nil |
| 165 | } |
| 166 | |
| 167 | func (fs *subDirFSscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/subDirFS#) Openscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/subDirFS#Open().(p string) (ioscip-go gomod github.com/golang/go/src go1.21 io/.ReadCloserscip-go gomod github.com/golang/go/src go1.21 io/ReadCloser#, error) { |
| 168 | parts := stringsscip-go gomod github.com/golang/go/src go1.21 strings/.SplitNscip-go gomod github.com/golang/go/src go1.21 strings/SplitN().(filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Cleanscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Clean().(p), string(filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Separatorscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Separator.), 2) |
| 169 | if len(parts) == 0 { |
| 170 | return ioscip-go gomod github.com/golang/go/src go1.21 io/.NopCloserscip-go gomod github.com/golang/go/src go1.21 io/NopCloser().(&emptyReaderscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/emptyReader#{}), nil |
| 171 | } |
| 172 | d, ok := fs.mscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/subDirFS#m.[parts[0]] |
| 173 | if !ok { |
| 174 | return nil, errorsscip-go gomod github.com/pkg/errors v0.9.1 `github.com/pkg/errors`/.WithStackscip-go gomod github.com/pkg/errors v0.9.1 `github.com/pkg/errors`/WithStack().(&osscip-go gomod github.com/golang/go/src go1.21 os/.PathErrorscip-go gomod github.com/golang/go/src go1.21 os/PathError#{Pathscip-go gomod github.com/golang/go/src go1.21 `io/fs`/PathError#Path.: parts[0], Errscip-go gomod github.com/golang/go/src go1.21 `io/fs`/PathError#Err.: syscallscip-go gomod github.com/golang/go/src go1.21 syscall/.ENOENTscip-go gomod github.com/golang/go/src go1.21 syscall/ENOENT., Opscip-go gomod github.com/golang/go/src go1.21 `io/fs`/PathError#Op.: "open"}) |
| 175 | } |
| 176 | return d.FSscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/Dir#FS..Openscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/FS#Open.(parts[1]) |
| 177 | } |
| 178 | |
| 179 | type emptyReaderscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/emptyReader# struct{} |
| 180 | |
| 181 | func (*emptyReaderscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/emptyReader#) Readscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/emptyReader#Read().([]byte) (int, error) { |
| 182 | return 0, ioscip-go gomod github.com/golang/go/src go1.21 io/.EOFscip-go gomod github.com/golang/go/src go1.21 io/EOF. |
| 183 | } |
| 184 | |
| 185 | type StatInfoscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/StatInfo# struct { |
| 186 | *typesscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/.Statscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/StatInfo#Stat. |
| 187 | } |
| 188 | |
| 189 | func (s *StatInfoscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/StatInfo#) Namescip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/StatInfo#Name().() string { |
| 190 | return filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Basescip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Base().(s.Statscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/StatInfo#Stat..Pathscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/Stat#Path.) |
| 191 | } |
| 192 | |
| 193 | func (s *StatInfoscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/StatInfo#) Sizescip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/StatInfo#Size().() int64 { |
| 194 | return s.Statscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/StatInfo#Stat..Sizescip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/Stat#Size. |
| 195 | } |
| 196 | |
| 197 | func (s *StatInfoscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/StatInfo#) Modescip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/StatInfo#Mode().() osscip-go gomod github.com/golang/go/src go1.21 os/.FileModescip-go gomod github.com/golang/go/src go1.21 os/FileMode# { |
| 198 | return osscip-go gomod github.com/golang/go/src go1.21 os/.FileModescip-go gomod github.com/golang/go/src go1.21 os/FileMode#(s.Statscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/StatInfo#Stat..Modescip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/Stat#Mode.) |
| 199 | } |
| 200 | |
| 201 | func (s *StatInfoscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/StatInfo#) ModTimescip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/StatInfo#ModTime().() timescip-go gomod github.com/golang/go/src go1.21 time/.Timescip-go gomod github.com/golang/go/src go1.21 time/Time# { |
| 202 | return timescip-go gomod github.com/golang/go/src go1.21 time/.Unixscip-go gomod github.com/golang/go/src go1.21 time/Unix().(s.Statscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/StatInfo#Stat..ModTimescip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/Stat#ModTime./1e9, s.Statscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/StatInfo#Stat..ModTimescip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/Stat#ModTime.%1e9) |
| 203 | } |
| 204 | |
| 205 | func (s *StatInfoscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/StatInfo#) IsDirscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/StatInfo#IsDir().() bool { |
| 206 | return s.Modescip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/StatInfo#Mode().().IsDirscip-go gomod github.com/golang/go/src go1.21 `io/fs`/FileMode#IsDir().() |
| 207 | } |
| 208 | |
| 209 | func (s *StatInfoscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/StatInfo#) Sysscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/StatInfo#Sys().() interface{} { |
| 210 | return s.Statscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/StatInfo#Stat. |
| 211 | } |
| 212 | |
| 213 | type DirEntryInfoscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/DirEntryInfo# struct { |
| 214 | *typesscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/.Statscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/DirEntryInfo#Stat. |
| 215 | |
| 216 | entryscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/DirEntryInfo#entry. gofsscip-go gomod github.com/golang/go/src go1.21 `io/fs`/.DirEntryscip-go gomod github.com/golang/go/src go1.21 `io/fs`/DirEntry# |
| 217 | pathscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/DirEntryInfo#path. string |
| 218 | origpathscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/DirEntryInfo#origpath. string |
| 219 | seenFilesscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/DirEntryInfo#seenFiles. map[uint64]string |
| 220 | } |
| 221 | |
| 222 | func (s *DirEntryInfoscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/DirEntryInfo#) Namescip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/DirEntryInfo#Name().() string { |
| 223 | if s.Statscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/DirEntryInfo#Stat. != nil { |
| 224 | return filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.Basescip-go gomod github.com/golang/go/src go1.21 `path/filepath`/Base().(s.Statscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/DirEntryInfo#Stat..Pathscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/Stat#Path.) |
| 225 | } |
| 226 | return s.entryscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/DirEntryInfo#entry..Namescip-go gomod github.com/golang/go/src go1.21 `io/fs`/DirEntry#Name().() |
| 227 | } |
| 228 | |
| 229 | func (s *DirEntryInfoscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/DirEntryInfo#) IsDirscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/DirEntryInfo#IsDir().() bool { |
| 230 | if s.Statscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/DirEntryInfo#Stat. != nil { |
| 231 | return s.Statscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/DirEntryInfo#Stat..IsDirscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/Stat#IsDir().() |
| 232 | } |
| 233 | return s.entryscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/DirEntryInfo#entry..IsDirscip-go gomod github.com/golang/go/src go1.21 `io/fs`/DirEntry#IsDir().() |
| 234 | } |
| 235 | |
| 236 | func (s *DirEntryInfoscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/DirEntryInfo#) Typescip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/DirEntryInfo#Type().() gofsscip-go gomod github.com/golang/go/src go1.21 `io/fs`/.FileModescip-go gomod github.com/golang/go/src go1.21 `io/fs`/FileMode# { |
| 237 | if s.Statscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/DirEntryInfo#Stat. != nil { |
| 238 | return gofsscip-go gomod github.com/golang/go/src go1.21 `io/fs`/.FileModescip-go gomod github.com/golang/go/src go1.21 `io/fs`/FileMode#(s.Statscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/DirEntryInfo#Stat..Modescip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/Stat#Mode.) |
| 239 | } |
| 240 | return s.entryscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/DirEntryInfo#entry..Typescip-go gomod github.com/golang/go/src go1.21 `io/fs`/DirEntry#Type().() |
| 241 | } |
| 242 | |
| 243 | func (s *DirEntryInfoscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/DirEntryInfo#) Infoscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/DirEntryInfo#Info().() (gofsscip-go gomod github.com/golang/go/src go1.21 `io/fs`/.FileInfoscip-go gomod github.com/golang/go/src go1.21 `io/fs`/FileInfo#, error) { |
| 244 | if s.Statscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/DirEntryInfo#Stat. == nil { |
| 245 | fi, err := s.entryscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/DirEntryInfo#entry..Infoscip-go gomod github.com/golang/go/src go1.21 `io/fs`/DirEntry#Info().() |
| 246 | if err != nil { |
| 247 | return nil, err |
| 248 | } |
| 249 | stat, err := mkstatscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/mkstat().(s.origpathscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/DirEntryInfo#origpath., s.pathscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/DirEntryInfo#path., fi, s.seenFilesscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/DirEntryInfo#seenFiles.) |
| 250 | if err != nil { |
| 251 | return nil, err |
| 252 | } |
| 253 | s.Statscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/DirEntryInfo#Stat. = stat |
| 254 | } |
| 255 | |
| 256 | st := s.Statscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/DirEntryInfo#Stat..Clonescip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/Stat#Clone().() |
| 257 | return &StatInfoscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/StatInfo#{st}, nil |
| 258 | } |