MCPcopy
hub / github.com/keploy/keploy / ToAbsPath

Function ToAbsPath

utils/utils.go:747–765  ·  view source on GitHub ↗
(logger *zap.Logger, originalPath string)

Source from the content-addressed store, hash-verified

745}
746
747func ToAbsPath(logger *zap.Logger, originalPath string) string {
748 path := originalPath
749 //if user provides relative path
750 if len(path) > 0 && path[0] != '/' {
751 absPath, err := filepath.Abs(path)
752 if err != nil {
753 LogError(logger, err, "failed to get the absolute path from relative path")
754 }
755 path = absPath
756 } else if len(path) == 0 { // if user doesn't provide any path
757 cdirPath, err := os.Getwd()
758 if err != nil {
759 LogError(logger, err, "failed to get the path of current directory")
760 }
761 path = cdirPath
762 }
763 path += "/keploy"
764 return path
765}
766
767// makeDirectory creates a directory if not exists with all user access
768func makeDirectory(path string) error {

Callers 1

ValidateFlagsMethod · 0.92

Calls 1

LogErrorFunction · 0.85

Tested by

no test coverage detected