MCPcopy Create free account
hub / github.com/bufbuild/buf / fsRootAndFSRelPathForPath

Function fsRootAndFSRelPathForPath

private/buf/buffetch/internal/reader.go:853–866  ·  view source on GitHub ↗

fsRootAndFSRelPathForPath is a helper function that takes a path and returns the FS root and relative path to the FS root.

(path string)

Source from the content-addressed store, hash-verified

851// fsRootAndFSRelPathForPath is a helper function that takes a path and returns the FS
852// root and relative path to the FS root.
853func fsRootAndFSRelPathForPath(path string) (string, string, error) {
854 absPath, err := normalpath.NormalizeAndAbsolute(path)
855 if err != nil {
856 return "", "", err
857 }
858 // Split the absolute path into components to get the FS root
859 absPathComponents := normalpath.Components(absPath)
860 fsRoot := absPathComponents[0]
861 fsRelPath, err := normalpath.Rel(fsRoot, absPath)
862 if err != nil {
863 return "", "", err
864 }
865 return fsRoot, fsRelPath, nil
866}
867
868// We attempt to fix up paths we get back to better printing to the user.
869// Without this, we'll get things like "stat: Users/foo/path/to/input: does not exist"

Callers 2

getReadWriteBucketForOSFunction · 0.85
getPWDFSRelPathFunction · 0.85

Calls 3

NormalizeAndAbsoluteFunction · 0.92
ComponentsFunction · 0.92
RelFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…