Debian Codegraph @

osfs/os_rootfs.go

raw symbols SCIP
1 //go:build !js
2
3 package osfsscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/
4
5 import (
6 "errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/"
7 "fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/"
8 gofsscip-go gomod github.com/golang/go/src go1.25.0 `io/fs`/ "io/fsscip-go gomod github.com/golang/go/src go1.25.0 `io/fs`/"
9 "osscip-go gomod github.com/golang/go/src go1.25.0 os/"
10 "path/filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/"
11 "stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/"
12
13 "github.com/go-git/go-billy/v6scip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/"
14 "github.com/go-git/go-billy/v6/helper/chrootscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/helper/chroot`/"
15 "github.com/go-git/go-billy/v6/utilscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/util`/"
16 )
17
18 // FromRoot creates a new [RootOS] from an [os.Root].
19 // The provided root is used directly for all operations and the caller
20 // is responsible for its lifecycle. Root must not be nil.
21 //
22 // [WithMmap] enables an mmap-backed [billy.File] from [RootOS.Open]
23 // (and [RootOS.OpenFile] when opened read-only) on supported
24 // platforms; all other [Option] values are accepted for API
25 // compatibility but have no effect.
26 func FromRootscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/FromRoot().(root *osscip-go gomod github.com/golang/go/src go1.25.0 os/.Rootscip-go gomod github.com/golang/go/src go1.25.0 os/Root#, opts ...Optionscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/Option#) (*RootOSscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#, error) {
27 if root == nil {
28 return nil, errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/.Newscip-go gomod github.com/golang/go/src go1.25.0 errors/New().("root must not be nil")
29 }
30 o := &optionsscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/options#{}
31 for _, opt := range opts {
32 opt(o)
33 }
34 return &RootOSscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#{rootscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#root.: root, mmapscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#mmap.: o.mmapscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/options#mmap.}, nil
35 }
36
37 // RootOS is a high-performance fs implementation based on a caller-managed
38 // [os.Root]. Since the root is reused across all operations, this avoids
39 // the overhead of opening and closing it on every call. The caller is
40 // responsible for the root's lifecycle.
41 //
42 // For automatic lifecycle management at the cost of per-operation overhead,
43 // use [BoundOS] via [New] instead.
44 //
45 // Behaviours of note:
46 // 1. Read and write operations can only be directed to files which descend
47 // from the root dir.
48 // 2. Symlink targets are stored verbatim and not rewritten, so they may
49 // point outside the root dir or to non-existent paths. [RootOS.Readlink]
50 // returns the stored target with path separators normalised to forward
51 // slashes (see [filepath.ToSlash]).
52 // 3. Operations leading to escapes to outside the [os.Root] location result
53 // in [ErrPathEscapesParent].
54 type RootOSscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS# struct {
55 rootscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#root. *osscip-go gomod github.com/golang/go/src go1.25.0 os/.Rootscip-go gomod github.com/golang/go/src go1.25.0 os/Root#
56 mmapscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#mmap. bool
57 }
58
59 func (fs *RootOSscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#) Capabilitiesscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#Capabilities().() billyscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/.Capabilityscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/Capability# {
60 return boundCapabilitiesscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/boundCapabilities().()
61 }
62
63 func (fs *RootOSscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#) Createscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#Create().(name string) (billyscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/.Filescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/File#, error) {
64 return fs.OpenFilescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#OpenFile().(name, osscip-go gomod github.com/golang/go/src go1.25.0 os/.O_RDWRscip-go gomod github.com/golang/go/src go1.25.0 os/O_RDWR.|osscip-go gomod github.com/golang/go/src go1.25.0 os/.O_CREATEscip-go gomod github.com/golang/go/src go1.25.0 os/O_CREATE.|osscip-go gomod github.com/golang/go/src go1.25.0 os/.O_TRUNCscip-go gomod github.com/golang/go/src go1.25.0 os/O_TRUNC., defaultCreateModescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/defaultCreateMode.)
65 }
66
67 func (fs *RootOSscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#) OpenFilescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#OpenFile().(name string, flag int, perm gofsscip-go gomod github.com/golang/go/src go1.25.0 `io/fs`/.FileModescip-go gomod github.com/golang/go/src go1.25.0 `io/fs`/FileMode#) (billyscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/.Filescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/File#, error) {
68 rel := fs.toRelativescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#toRelative().(name)
69 display := fs.displayNamescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#displayName().(name)
70
71 if flag&osscip-go gomod github.com/golang/go/src go1.25.0 os/.O_CREATEscip-go gomod github.com/golang/go/src go1.25.0 os/O_CREATE. != 0 {
72 if err := createDirscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/createDir().(fs.rootscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#root., rel); err != nil {
73 return nil, translateErrorscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/translateError().(err, rel)
74 }
75 }
76
77 openName := rel
78 if openName == "" {
79 openName = "."
80 }
81 f, err := fs.rootscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#root..OpenFilescip-go gomod github.com/golang/go/src go1.25.0 os/Root#OpenFile().(openName, flag, perm)
82 if err == nil {
83 return fs.wrapOpenedFilescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#wrapOpenedFile().(f, display, flag)
84 }
85
86 // os.Root rejects an absolute symlink target even when it points back
87 // inside the same root. Resolve that one case to keep existing Billy
88 // symlink behavior without allowing a real root escape.
89 if flag&osscip-go gomod github.com/golang/go/src go1.25.0 os/.O_CREATEscip-go gomod github.com/golang/go/src go1.25.0 os/O_CREATE. == 0 && isPathEscapeErrorscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/isPathEscapeError().(err) {
90 escapeErr := err
91 fi, lstatErr := fs.rootscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#root..Lstatscip-go gomod github.com/golang/go/src go1.25.0 os/Root#Lstat().(openName)
92 if lstatErr == nil && fi.Modescip-go gomod github.com/golang/go/src go1.25.0 `io/fs`/FileInfo#Mode().()&gofsscip-go gomod github.com/golang/go/src go1.25.0 `io/fs`/.ModeSymlinkscip-go gomod github.com/golang/go/src go1.25.0 `io/fs`/ModeSymlink. != 0 {
93 if target, readlinkErr := fs.rootscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#root..Readlinkscip-go gomod github.com/golang/go/src go1.25.0 os/Root#Readlink().(openName); readlinkErr == nil {
94 if targetRel, ok := fs.absoluteSymlinkTargetscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#absoluteSymlinkTarget().(target); ok {
95 if f, err = fs.rootscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#root..OpenFilescip-go gomod github.com/golang/go/src go1.25.0 os/Root#OpenFile().(targetRel, flag, perm); err == nil {
96 return fs.wrapOpenedFilescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#wrapOpenedFile().(f, display, flag)
97 }
98 }
99 }
100 }
101 err = escapeErr
102 }
103
104 return nil, translateErrorscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/translateError().(err, rel)
105 }
106
107 // wrapOpenedFile picks the [billy.File] shape for f based on the
108 // filesystem's [WithMmap] configuration and the open flags. For
109 // read-only opens on [WithMmap]-configured filesystems on supported
110 // platforms it returns a [*mmapFile]; in every other case (write
111 // access, mmap disabled, platforms without mmap support, or mmap
112 // unavailable for this specific file) it returns the regular [*file]
113 // wrapper around the underlying [*os.File].
114 func (fs *RootOSscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#) wrapOpenedFilescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#wrapOpenedFile().(f *osscip-go gomod github.com/golang/go/src go1.25.0 os/.Filescip-go gomod github.com/golang/go/src go1.25.0 os/File#, name string, flag int) (billyscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/.Filescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/File#, error) {
115 if fs.mmapscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#mmap. && flag&(osscip-go gomod github.com/golang/go/src go1.25.0 os/.O_WRONLYscip-go gomod github.com/golang/go/src go1.25.0 os/O_WRONLY.|osscip-go gomod github.com/golang/go/src go1.25.0 os/.O_RDWRscip-go gomod github.com/golang/go/src go1.25.0 os/O_RDWR.) == 0 {
116 mf, err := newMmapFilescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/newMmapFile().(f, name)
117 if err == nil {
118 return mf, nil
119 }
120 if !errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/.Isscip-go gomod github.com/golang/go/src go1.25.0 errors/Is().(err, errMmapUnavailablescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/errMmapUnavailable.) {
121 // Real failure (e.g. stat); newMmapFile already closed f.
122 return nil, err
123 }
124 // Fall through to the regular wrapper.
125 }
126 return &filescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/file#{Filescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/file#File.: f, namescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/file#name.: name}, nil
127 }
128
129 func (fs *RootOSscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#) ReadDirscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#ReadDir().(name string) ([]gofsscip-go gomod github.com/golang/go/src go1.25.0 `io/fs`/.DirEntryscip-go gomod github.com/golang/go/src go1.25.0 `io/fs`/DirEntry#, error) {
130 rel := fs.toRelativescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#toRelative().(name)
131 if rel == "" {
132 rel = "."
133 }
134
135 f, err := fs.rootscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#root..Openscip-go gomod github.com/golang/go/src go1.25.0 os/Root#Open().(rel)
136 if err != nil {
137 return nil, translateErrorscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/translateError().(err, rel)
138 }
139 defer f.Closescip-go gomod github.com/golang/go/src go1.25.0 os/File#Close().()
140
141 e, err := f.ReadDirscip-go gomod github.com/golang/go/src go1.25.0 os/File#ReadDir().(-1)
142 if err != nil {
143 return nil, translateErrorscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/translateError().(err, rel)
144 }
145 return e, nil
146 }
147
148 func (fs *RootOSscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#) Renamescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#Rename().(from, to string) error {
149 if fs.isBaseDirscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#isBaseDir().(from) {
150 return billyscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/.ErrBaseDirCannotBeRenamedscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/ErrBaseDirCannotBeRenamed.
151 }
152
153 fromRel := fs.toRelativescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#toRelative().(from)
154 toRel := fs.toRelativescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#toRelative().(to)
155
156 if err := createDirscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/createDir().(fs.rootscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#root., toRel); err != nil {
157 return translateErrorscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/translateError().(err, toRel)
158 }
159
160 return translateErrorscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/translateError().(fs.rootscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#root..Renamescip-go gomod github.com/golang/go/src go1.25.0 os/Root#Rename().(fromRel, toRel), fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Sprintf().("%s -> %s", fromRel, toRel))
161 }
162
163 func (fs *RootOSscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#) MkdirAllscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#MkdirAll().(name string, perm gofsscip-go gomod github.com/golang/go/src go1.25.0 `io/fs`/.FileModescip-go gomod github.com/golang/go/src go1.25.0 `io/fs`/FileMode#) error {
164 rel := fs.toRelativescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#toRelative().(name)
165 if rel == "" {
166 rel = "."
167 }
168
169 // os.Root errors when perm contains bits other than the nine least-significant bits (0o777).
170 err := fs.rootscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#root..MkdirAllscip-go gomod github.com/golang/go/src go1.25.0 os/Root#MkdirAll().(rel, perm&0o777)
171 return translateErrorscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/translateError().(err, rel)
172 }
173
174 func (fs *RootOSscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#) Openscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#Open().(name string) (billyscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/.Filescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/File#, error) {
175 return fs.OpenFilescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#OpenFile().(name, osscip-go gomod github.com/golang/go/src go1.25.0 os/.O_RDONLYscip-go gomod github.com/golang/go/src go1.25.0 os/O_RDONLY., 0)
176 }
177
178 func (fs *RootOSscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#) Statscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#Stat().(name string) (osscip-go gomod github.com/golang/go/src go1.25.0 os/.FileInfoscip-go gomod github.com/golang/go/src go1.25.0 os/FileInfo#, error) {
179 rel := fs.toRelativescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#toRelative().(name)
180 if rel == "" {
181 rel = "."
182 }
183
184 fi, err := fs.rootscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#root..Statscip-go gomod github.com/golang/go/src go1.25.0 os/Root#Stat().(rel)
185 if err != nil {
186 return nil, translateErrorscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/translateError().(err, rel)
187 }
188
189 return fileInfoscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/fileInfo#{FileInfoscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/fileInfo#FileInfo.: fi, namescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/fileInfo#name.: filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.Basescip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/Base().(fs.displayNamescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#displayName().(name))}, nil
190 }
191
192 func (fs *RootOSscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#) Removescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#Remove().(name string) error {
193 if fs.isBaseDirscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#isBaseDir().(name) {
194 return billyscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/.ErrBaseDirCannotBeRemovedscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/ErrBaseDirCannotBeRemoved.
195 }
196
197 rel := fs.toRelativescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#toRelative().(name)
198 err := fs.rootscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#root..Removescip-go gomod github.com/golang/go/src go1.25.0 os/Root#Remove().(rel)
199 if err == nil {
200 return nil
201 }
202
203 return translateErrorscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/translateError().(err, rel)
204 }
205
206 // TempFile creates a temporary file. If dir is empty, the file
207 // will be created within a .tmp dir.
208 func (fs *RootOSscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#) TempFilescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#TempFile().(dir, prefix string) (billyscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/.Filescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/File#, error) {
209 return utilscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/util`/.TempFilescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/util`/TempFile().(fs, dir, prefix)
210 }
211
212 func (fs *RootOSscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#) Joinscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#Join().(elem ...string) string {
213 return filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/Join().(elem...)
214 }
215
216 func (fs *RootOSscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#) RemoveAllscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#RemoveAll().(name string) error {
217 if fs.isBaseDirscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#isBaseDir().(name) {
218 return billyscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/.ErrBaseDirCannotBeRemovedscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/ErrBaseDirCannotBeRemoved.
219 }
220
221 rel := fs.toRelativescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#toRelative().(name)
222 return translateErrorscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/translateError().(fs.rootscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#root..RemoveAllscip-go gomod github.com/golang/go/src go1.25.0 os/Root#RemoveAll().(rel), rel)
223 }
224
225 func (fs *RootOSscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#) Symlinkscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#Symlink().(oldname, newname string) error {
226 newRel := fs.toRelativescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#toRelative().(newname)
227
228 if err := createDirscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/createDir().(fs.rootscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#root., newRel); err != nil {
229 return translateErrorscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/translateError().(err, newRel)
230 }
231
232 return translateErrorscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/translateError().(fs.rootscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#root..Symlinkscip-go gomod github.com/golang/go/src go1.25.0 os/Root#Symlink().(oldname, newRel), newRel)
233 }
234
235 func (fs *RootOSscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#) Lstatscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#Lstat().(name string) (osscip-go gomod github.com/golang/go/src go1.25.0 os/.FileInfoscip-go gomod github.com/golang/go/src go1.25.0 os/FileInfo#, error) {
236 rel := fs.toRelativescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#toRelative().(name)
237 if rel == "" {
238 rel = "."
239 }
240
241 fi, err := fs.rootscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#root..Lstatscip-go gomod github.com/golang/go/src go1.25.0 os/Root#Lstat().(rel)
242 if err != nil {
243 return nil, translateErrorscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/translateError().(err, rel)
244 }
245
246 return fileInfoscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/fileInfo#{FileInfoscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/fileInfo#FileInfo.: fi, namescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/fileInfo#name.: filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.Basescip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/Base().(fs.displayNamescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#displayName().(name))}, nil
247 }
248
249 func (fs *RootOSscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#) Readlinkscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#Readlink().(name string) (string, error) {
250 rel := fs.toRelativescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#toRelative().(name)
251 if rel == "" {
252 rel = "."
253 }
254
255 lnk, err := fs.rootscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#root..Readlinkscip-go gomod github.com/golang/go/src go1.25.0 os/Root#Readlink().(rel)
256 if err != nil {
257 return "", translateErrorscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/translateError().(err, rel)
258 }
259
260 return filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.ToSlashscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/ToSlash().(lnk), nil
261 }
262
263 func (fs *RootOSscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#) Chmodscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#Chmod().(path string, mode gofsscip-go gomod github.com/golang/go/src go1.25.0 `io/fs`/.FileModescip-go gomod github.com/golang/go/src go1.25.0 `io/fs`/FileMode#) error {
264 rel := fs.toRelativescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#toRelative().(path)
265 if rel == "" {
266 rel = "."
267 }
268 return translateErrorscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/translateError().(fs.rootscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#root..Chmodscip-go gomod github.com/golang/go/src go1.25.0 os/Root#Chmod().(rel, mode), rel)
269 }
270
271 // Chroot returns a logical sub-filesystem rooted at the result of joining
272 // the provided path with the underlying root dir. The returned filesystem
273 // reuses this [RootOS]'s [os.Root] (no new file descriptor is opened),
274 // so its lifecycle is tied to the parent root managed by the caller.
275 //
276 // If path does not yet exist under the parent root it is created (with
277 // [defaultDirectoryMode]). If path exists but is not a directory an error
278 // is returned.
279 //
280 // Containment is enforced by the parent [os.Root], not by the chroot
281 // path: operations cannot escape the parent root, but a symlink within
282 // the chroot may resolve to a sibling location elsewhere under the
283 // parent root. For a tighter boundary at the chroot path, open a new
284 // [os.Root] via [os.OpenRoot] and wrap it with [FromRoot].
285 func (fs *RootOSscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#) Chrootscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#Chroot().(path string) (billyscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/.Filesystemscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6`/Filesystem#, error) {
286 rel := fs.toRelativescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#toRelative().(path)
287 if rel == "" {
288 rel = "."
289 }
290
291 if err := ensureDirscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/ensureDir().(fs.rootscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#root., rel); err != nil {
292 return nil, err
293 }
294
295 return chrootscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/helper/chroot`/.Newscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/helper/chroot`/New().(fs, filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/Join().(fs.rootscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#root..Namescip-go gomod github.com/golang/go/src go1.25.0 os/Root#Name().(), rel)), nil
296 }
297
298 // Root returns the current root dir of the filesystem.
299 func (fs *RootOSscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#) Rootscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#Root().() string {
300 return fs.rootscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#root..Namescip-go gomod github.com/golang/go/src go1.25.0 os/Root#Name().()
301 }
302
303 func (fs *RootOSscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#) displayNamescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#displayName().(name string) string {
304 name = hostPathscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/hostPath().(name)
305 if filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.IsAbsscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/IsAbs().(name) && isHostRootscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/isHostRoot().(fs.rootscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#root..Namescip-go gomod github.com/golang/go/src go1.25.0 os/Root#Name().()) {
306 return filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.Cleanscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/Clean().(name)
307 }
308
309 rel := fs.toRelativescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#toRelative().(name)
310 if rel == "" {
311 return "."
312 }
313 return rel
314 }
315
316 func (fs *RootOSscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#) isBaseDirscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#isBaseDir().(name string) bool {
317 rel := fs.toRelativescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#toRelative().(name)
318 return rel == "" || rel == "."
319 }
320
321 func (fs *RootOSscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#) toRelativescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#toRelative().(name string) string {
322 if name == "" {
323 return ""
324 }
325
326 name = hostPathscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/hostPath().(name)
327 if filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.IsAbsscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/IsAbs().(name) {
328 if rel, ok := relativeInsideBasescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/relativeInsideBase().(fs.rootscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#root..Namescip-go gomod github.com/golang/go/src go1.25.0 os/Root#Name().(), name); ok {
329 return cleanUnderRootscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/cleanUnderRoot().(rel)
330 }
331 }
332
333 return cleanUnderRootscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/cleanUnderRoot().(name)
334 }
335
336 func (fs *RootOSscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#) absoluteSymlinkTargetscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#absoluteSymlinkTarget().(target string) (string, bool) {
337 if !isRootedPathscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/isRootedPath().(target) {
338 return "", false
339 }
340 target = hostPathscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/hostPath().(target)
341 rel, ok := relativeInsideBasescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/relativeInsideBase().(fs.rootscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/RootOS#root..Namescip-go gomod github.com/golang/go/src go1.25.0 os/Root#Name().(), target)
342 if !ok {
343 rel = cleanUnderRootscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/cleanUnderRoot().(target)
344 }
345 if rel == "" {
346 return ".", true
347 }
348 return cleanUnderRootscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/cleanUnderRoot().(rel), true
349 }
350
351 func relativeInsideBasescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/relativeInsideBase().(base, name string) (string, bool) {
352 base = hostPathscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/hostPath().(base)
353 name = hostPathscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/hostPath().(name)
354 rel, err := filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.Relscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/Rel().(filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.Cleanscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/Clean().(base), filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.Cleanscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/Clean().(name))
355 if err != nil {
356 return "", false
357 }
358 if rel == "." {
359 return "", true
360 }
361 if rel == ".." || stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.HasPrefixscip-go gomod github.com/golang/go/src go1.25.0 strings/HasPrefix().(rel, ".."+string(filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.Separatorscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/Separator.)) {
362 return "", false
363 }
364 return rel, true
365 }
366
367 func isRootedPathscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/isRootedPath().(name string) bool {
368 name = hostPathscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/hostPath().(name)
369 if filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.IsAbsscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/IsAbs().(name) {
370 return true
371 }
372 return stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.HasPrefixscip-go gomod github.com/golang/go/src go1.25.0 strings/HasPrefix().(name, string(filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.Separatorscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/Separator.))
373 }
374
375 func cleanUnderRootscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/cleanUnderRoot().(name string) string {
376 name = hostPathscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/hostPath().(name)
377 vol := filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.VolumeNamescip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/VolumeName().(name)
378 name = name[len(vol):]
379 name = filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/Join().(string(filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.Separatorscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/Separator.), name)
380 return stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.TrimLeftscip-go gomod github.com/golang/go/src go1.25.0 strings/TrimLeft().(name, string(filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.Separatorscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/Separator.))
381 }
382
383 func hostPathscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/hostPath().(name string) string {
384 name = filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.FromSlashscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/FromSlash().(name)
385 if filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.Separatorscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/Separator. == '\\' && len(name) >= 3 &&
386 name[0] == '\\' && name[2] == ':' {
387 return name[1:]
388 }
389 return name
390 }
391
392 func isHostRootscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/isHostRoot().(name string) bool {
393 name = filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.Cleanscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/Clean().(hostPathscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/hostPath().(name))
394 if !filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.IsAbsscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/IsAbs().(name) && !stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.HasPrefixscip-go gomod github.com/golang/go/src go1.25.0 strings/HasPrefix().(name, string(filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.Separatorscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/Separator.)) {
395 return false
396 }
397 return filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.Dirscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/Dir().(name) == name
398 }
399
400 func ensureDirscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/ensureDir().(root *osscip-go gomod github.com/golang/go/src go1.25.0 os/.Rootscip-go gomod github.com/golang/go/src go1.25.0 os/Root#, path string) error {
401 fi, err := root.Lstatscip-go gomod github.com/golang/go/src go1.25.0 os/Root#Lstat().(path)
402 if errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/.Isscip-go gomod github.com/golang/go/src go1.25.0 errors/Is().(err, osscip-go gomod github.com/golang/go/src go1.25.0 os/.ErrNotExistscip-go gomod github.com/golang/go/src go1.25.0 os/ErrNotExist.) {
403 if err := root.MkdirAllscip-go gomod github.com/golang/go/src go1.25.0 os/Root#MkdirAll().(path, defaultDirectoryModescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/defaultDirectoryMode.); err != nil {
404 return fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Errorf().("failed to auto create dir: %w", translateErrorscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/translateError().(err, path))
405 }
406 return nil
407 }
408 if err != nil {
409 return translateErrorscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/translateError().(err, path)
410 }
411 if fi != nil && !fi.IsDirscip-go gomod github.com/golang/go/src go1.25.0 `io/fs`/FileInfo#IsDir().() {
412 return fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Errorf().("cannot chroot: %q is not a dir (mode %s)", path, fi.Modescip-go gomod github.com/golang/go/src go1.25.0 `io/fs`/FileInfo#Mode().())
413 }
414 return nil
415 }
416
417 func createDirscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/createDir().(root *osscip-go gomod github.com/golang/go/src go1.25.0 os/.Rootscip-go gomod github.com/golang/go/src go1.25.0 os/Root#, fullpath string) error {
418 dir := filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.Dirscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/Dir().(fullpath)
419 if dir != "." {
420 if err := root.MkdirAllscip-go gomod github.com/golang/go/src go1.25.0 os/Root#MkdirAll().(dir, defaultDirectoryModescip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/defaultDirectoryMode.); err != nil {
421 if errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/.Isscip-go gomod github.com/golang/go/src go1.25.0 errors/Is().(err, osscip-go gomod github.com/golang/go/src go1.25.0 os/.ErrExistscip-go gomod github.com/golang/go/src go1.25.0 os/ErrExist.) {
422 return nil
423 }
424 return err
425 }
426 }
427
428 return nil
429 }
430
431 func isPathEscapeErrorscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/isPathEscapeError().(err error) bool {
432 return err != nil && stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Containsscip-go gomod github.com/golang/go/src go1.25.0 strings/Contains().(err.Error(), ErrPathEscapesParentscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/ErrPathEscapesParent..Error())
433 }
434
435 func translateErrorscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/translateError().(err error, file string) error {
436 if err == nil {
437 return nil
438 }
439
440 if isPathEscapeErrorscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/isPathEscapeError().(err) {
441 return fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Errorf().("%w: %q", ErrPathEscapesParentscip-go gomod github.com/go-git/go-billy/v6 . `github.com/go-git/go-billy/v6/osfs`/ErrPathEscapesParent., file)
442 }
443
444 return err
445 }