MCPcopy Create free account
hub / github.com/cli/cli / OpenRoot

Function OpenRoot

internal/safepaths/root.go:27–56  ·  view source on GitHub ↗

OpenRoot opens an existing directory as a rooted filesystem.

(path string)

Source from the content-addressed store, hash-verified

25
26// OpenRoot opens an existing directory as a rooted filesystem.
27func OpenRoot(path string) (*Root, error) {
28 absolute, err := ParseAbsolute(path)
29 if err != nil {
30 return nil, err
31 }
32
33 root, err := os.OpenRoot(absolute.String())
34 if err != nil {
35 return nil, err
36 }
37
38 return &Root{
39 root: root,
40 openRoot: func(root *os.Root, name string) (*os.Root, error) {
41 return root.OpenRoot(name)
42 },
43 openFile: func(root *os.Root, name string, flag int, perm os.FileMode) (*os.File, error) {
44 return root.OpenFile(name, flag, perm)
45 },
46 lstat: func(root *os.Root, name string) (os.FileInfo, error) {
47 return root.Lstat(name)
48 },
49 readlink: func(root *os.Root, name string) (string, error) {
50 return root.Readlink(name)
51 },
52 stat: func(root *os.Root, name string) (os.FileInfo, error) {
53 return root.Stat(name)
54 },
55 }, nil
56}
57
58// OpenRootDir creates and opens a user-selected directory as a rooted filesystem.
59// The selected path may contain symbolic links; child paths beneath the opened

Callers 15

extractZipFunction · 0.92
extractTarGzFunction · 0.92
Test_DownloadFunction · 0.92
TestFileCreationModesFunction · 0.92
TestRootCreateFunction · 0.92
TestValidateChildFunction · 0.92
Test_extractZipFunction · 0.92
TestRootRejectsJunctionFunction · 0.85
OpenRootDirFunction · 0.85
OpenFileFunction · 0.85

Calls 2

ParseAbsoluteFunction · 0.85
StringMethod · 0.65