// SplitPath splits a path by its driver and respective volume.  Returns
// error if the driver is not initialized.
10559
func SplitPath(volumePath string) (string, string, error) {
	// Validate the path
	rootDir := filepath.Clean(volumePath)
	if !filepath.IsAbs(rootDir) {
		// must be absolute
		return "", "", ErrPathIsNotAbs
	}
	if _, ok := driversByRoot[rootDir]; ok {
		return volumePath, "", nil
	}
	for {
		rootDir = filepath.Dir(rootDir)
		if _, ok := driversByRoot[rootDir]; !ok {
			// continue if the path is not '/'
			if rootDir == "/" {
				return "", "", ErrDriverNotInit
			}
		} else {
			// get the name of the volume
			if volumeName, err := filepath.Rel(rootDir, volumePath); err != nil {
				glog.Errorf("Unexpected error while looking up relpath of %s from %s: %s", volumePath, rootDir, err)
				return "", "", err
			} else {
				return rootDir, volumeName, nil
			}
		}
	}
}
1122828
func validateVolumeSourcePath(targetPath string, fldPath *validation.FieldPath) validation.ErrorList {
	allErrs := validation.ErrorList{}
	if path.IsAbs(targetPath) {
		allErrs = append(allErrs, validation.NewForbiddenError(fldPath, "must not be an absolute path"))
	}
	// TODO assume OS of api server & nodes are the same for now
	items := strings.Split(targetPath, string(os.PathSeparator))

	for _, item := range items {
		if item == ".." {
			allErrs = append(allErrs, validation.NewInvalidError(fldPath, targetPath, "must not contain \"..\""))
		}
	}
	if strings.HasPrefix(items[0], "..") && len(items[0]) > 2 {
		allErrs = append(allErrs, validation.NewInvalidError(fldPath, targetPath, "must not start with \"..\""))
	}
	return allErrs
}
742916
func (c *context) fullpath(p string) (string, error) {
	p = c.pathDriver.Join(c.root, p)
	if !strings.HasPrefix(p, c.root) {
		return "", fmt.Errorf("invalid context path")
	}

	return p, nil
}
67776
func SplitPath(p string) (bucket, path string) {
	if err := ValidatePath(p); err != nil {
		panic(err)
	}
	sep := strings.IndexByte(p[1:], '/') + 1
	return p[1:sep], p[sep+1:]
}
21819
func SplitPath(r *http.Request) []string {
	if len(r.URL.Path) == 0 {
		return nil
	}
	if len(r.URL.Path) == 1 && r.URL.Path[0] == '/' {
		return nil
	}
	return strings.Split(r.URL.Path[1:], "/")
}
419348
func splitActionPath(actionPathData *ActionPathData, actionPath string, useCache bool) (pathData *ActionPathData, found bool) {
	actionPath = strings.ToLower(actionPath)
	if pathData, found = actionPathCacheMap[actionPath]; found && useCache {
		return
	}
	var (
		controllerNamespace, controllerName, methodName, action string
		foundModuleSource                                       *Module
		typeOfController                                        *ControllerType
		log                                                     = routerLog.New("actionPath", actionPath)
	)
	actionSplit := strings.Split(actionPath, ".")
	if actionPathData != nil {
		foundModuleSource = actionPathData.ModuleSource
	}
	if len(actionSplit) == 2 {
		controllerName, methodName = strings.ToLower(actionSplit[0]), strings.ToLower(actionSplit[1])
		if i := strings.Index(methodName, "("); i > 0 {
			methodName = methodName[:i]
		}
		log = log.New("controller", controllerName, "method", methodName)
		log.Debug("splitActionPath: Check for namespace")
		if i := strings.Index(controllerName, namespaceSeperator); i > -1 {
			controllerNamespace = controllerName[:i+1]
			if moduleSource, found := ModuleByName(controllerNamespace[:len(controllerNamespace)-1]); found {
				log.Debug("Found module namespace")
				foundModuleSource = moduleSource
				controllerNamespace = moduleSource.Namespace()
			} else {
				log.Warnf("splitActionPath: Unable to find module %s for action: %s", controllerNamespace[:len(controllerNamespace)-1], actionPath)
			}
			controllerName = controllerName[i+1:]
			// Check for the type of controller
			typeOfController = foundModuleSource.ControllerByName(controllerName, methodName)
			found = typeOfController != nil
		} else if controllerName[0] != ':' {
			// First attempt to find the controller in the module source
			if foundModuleSource != nil {
				typeOfController = foundModuleSource.ControllerByName(controllerName, methodName)
				if typeOfController != nil {
					controllerNamespace = typeOfController.Namespace
				}
			}
			log.Info("Found controller for path", "controllerType", typeOfController)

			if typeOfController == nil {
				// Check to see if we can determine the controller from only the controller name
				// an actionPath without a moduleSource will only come from
				// Scan through the controllers
				matchName := controllerName
				for key, controller := range controllers {
					// Strip away the namespace from the controller. to be match
					regularName := key
					if i := strings.Index(key, namespaceSeperator); i > -1 {
						regularName = regularName[i+1:]
					}
					if regularName == matchName {
						// Found controller match
						typeOfController = controller
						controllerNamespace = typeOfController.Namespace
						controllerName = typeOfController.ShortName()
						foundModuleSource = typeOfController.ModuleSource
						found = true
						break
					}
				}
			} else {
				found = true
			}
		} else {
			// If wildcard assign the route the controller namespace found
			controllerNamespace = actionPathData.ModuleSource.Name + namespaceSeperator
			foundModuleSource = actionPathData.ModuleSource
			found = true
		}
		action = actionSplit[1]
	} else {
		foundPaths := ""
		for path := range actionPathCacheMap {
			foundPaths += path + ","
		}
		log.Warnf("splitActionPath: Invalid action path %s found paths %s", actionPath, foundPaths)
		found = false
	}

	// Make sure no concurrent map writes occur
	if found {
		actionPathCacheLock.Lock()
		defer actionPathCacheLock.Unlock()
		if actionPathData != nil {
			actionPathData.ControllerNamespace = controllerNamespace
			actionPathData.ControllerName = controllerName
			actionPathData.MethodName = methodName
			actionPathData.Action = action
			actionPathData.ModuleSource = foundModuleSource
			actionPathData.TypeOfController = typeOfController
		} else {
			actionPathData = &ActionPathData{
				ControllerNamespace: controllerNamespace,
				ControllerName:      controllerName,
				MethodName:          methodName,
				Action:              action,
				ModuleSource:        foundModuleSource,
				TypeOfController:    typeOfController,
			}
		}
		actionPathData.TypeOfController = foundModuleSource.ControllerByName(controllerName, "")
		if actionPathData.TypeOfController == nil && actionPathData.ControllerName[0] != ':' {
			log.Warnf("splitActionPath: No controller found for %s %#v", foundModuleSource.Namespace()+controllerName, controllers)
		}

		pathData = actionPathData
		if pathData.Route != nil && len(pathData.Route.FixedParams) > 0 {
			// If there are fixed params on the route then add them to the path
			// This will give it a unique path and it should still be usable for a reverse lookup provided the name is matchable
			// for example
			// GET   /test/                     Application.Index("Test", "Test2")
			// {{url "Application.Index(test,test)" }}
			// should be parseable
			actionPath = actionPath + "(" + strings.ToLower(strings.Join(pathData.Route.FixedParams, ",")) + ")"
		}
		if actionPathData.Route != nil {
			log.Debugf("splitActionPath: Split Storing recognized action path %s for route  %#v ", actionPath, actionPathData.Route)
		}
		pathData.Key = actionPath
		actionPathCacheMap[actionPath] = pathData
		if !strings.Contains(actionPath, namespaceSeperator) && pathData.TypeOfController != nil {
			actionPathCacheMap[strings.ToLower(pathData.TypeOfController.Namespace)+actionPath] = pathData
			log.Debugf("splitActionPath: Split Storing recognized action path %s for route  %#v ", strings.ToLower(pathData.TypeOfController.Namespace)+actionPath, actionPathData.Route)
		}
	}
	return
}
546304
func Path(named Named) (name string) {
	if r, ok := named.(namedRepository); ok {
		return r.Path()
	}
	_, path := splitDomain(named.Name())
	return path
}
701373
func GOPATH() []string {
	paths := strings.Split(os.Getenv("GOPATH"), string(os.PathListSeparator))
	if len(paths) == 0 {
		fmt.Println("GOPATH doesn't exist")
	}
	return paths
}
792588
func (f *flexVolume) GetPath() string {
	name := f.driverName
	return f.plugin.host.GetPodVolumeDir(f.podUID, utilstrings.EscapeQualifiedName(name), f.volName)
}
1297012
func SplitCompact(rdr io.Reader) ([]byte, []byte, []byte, error) {
	var protected []byte
	var payload []byte
	var signature []byte
	var periods int
	var state int

	buf := make([]byte, 4096)
	var sofar []byte

	for {
		n, err := rdr.Read(buf)
		if n == 0 && err != nil {
			break
		}

		sofar = append(sofar, buf[:n]...)
		for loop := true; loop; {
			i := bytes.IndexByte(sofar, '.')
			switch i {
			case -1:
				l := len(sofar)
				if l <= 0 {
					loop = false
					continue
				}
				i = l
			default:
				periods++
			}

			switch state {
			case 0:
				protected = sofar[:i]
				state++
			case 1:
				payload = sofar[:i]
				state++
			case 2:
				signature = sofar[:i]
			}
			if len(sofar) <= i {
				sofar = []byte(nil)
			} else {
				sofar = sofar[i+1:]
			}
		}
	}
	if periods != 2 {
		return nil, nil, nil, errors.New(`invalid number of segments`)
	}

	return protected, payload, signature, nil
}
502682
func (n *roFileVersion) fullPath() string {
	if n == nil {
		return ""
	}
	return filepath.Join(n.parent.fullPath(), n.name)
}
521957
func splitSubdomainAndPath(fullUnparsedPath string) (subdomain string, path string) {
	s := fullUnparsedPath
	if s == "" || s == "/" {
		return "", "/"
	}

	slashIdx := strings.IndexByte(s, '/')
	if slashIdx == 0 {
		// no subdomain
		return "", cleanPath(s)
	}

	return s[0:slashIdx], cleanPath(s[slashIdx:]) // return subdomain without slash, path with slash
}
607327
func splitUSTARPath(name string) (prefix, suffix string, ok bool) {
	length := len(name)
	if length <= nameSize || !isASCII(name) {
		return "", "", false
	} else if length > prefixSize+1 {
		length = prefixSize + 1
	} else if name[length-1] == '/' {
		length--
	}

	i := strings.LastIndex(name[:length], "/")
	nlen := len(name) - i - 1 // nlen is length of suffix
	plen := i                 // plen is length of prefix
	if i <= 0 || nlen > nameSize || nlen == 0 || plen > prefixSize {
		return "", "", false
	}
	return name[:i], name[i+1:], true
}
1183685
func (b *binary) Path(parts ...string) string {
	args := make([]string, len(parts)+1)
	args[0] = b.workDir
	args = append(args, parts...)
	return filepath.Join(args...)
}
417936
func (m *Iteration) FullPath() string {
	return m.Path.String() + path.SepInService + m.ID.String()
}
540655
func splitRepository(fullRepo string) (registry string, path string) {
	parts := strings.Split(fullRepo, "/")

	if len(parts) < 2 {
		return "", parts[0]
	}

	if len(parts) == 2 {
		return "", strings.Join(parts, "/")
	}

	return parts[0], strings.Join(parts[1:], "/")
}
1086766
func expandPath(s string) string {
	if s == "" {
		return ""
	}

	e, err := homedir.Expand(s)
	if err != nil {
		return s
	}
	return e
}