// ParsePath extracts episode info from a full path
549237
func ParsePath(path string) (*EpisodeInfo, error) {
	path = normalizePath(path)
	name := filepath.Base(path)
	dir := filepath.Base(filepath.Dir(path))
	ext := filepath.Ext(path)

	for _, test := range []string{
		name,             // path name
		dir + " " + name, // dirname + name of the file
		dir + ext,        // dirname + extentions
	} {
		result, err := Parse(test)
		if err == nil {
			return result, err
		}
	}

	return nil, fmt.Errorf("Unable to parse path %s", path)
}
1104380
func parseMigrationPath(path string) (uint64, migrationType, string, error) {
	filebase := filepath.Base(path)

	matches := upMigrationFile.FindAllSubmatch([]byte(filebase), -1)
	if matches != nil {
		return parseMatches(matches, upMigration)
	}
	matches = downMigrationFile.FindAllSubmatch([]byte(filebase), -1)
	if matches != nil {
		return parseMatches(matches, downMigration)
	}

	return 0, "", "", InvalidMigrationFile
}
589584
func (ctx *context) RequestPath(escape bool) string {
	if escape {
		return DecodeQuery(ctx.request.URL.EscapedPath())
	}
	return ctx.request.URL.Path // RawPath returns empty, requesturi can be used instead also.
}
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...)
}
454851
func (r *ResourceDefinition) FullPath() string {
	if strings.HasPrefix(r.BasePath, "//") {
		return httppath.Clean(r.BasePath)
	}
	var basePath string
	if p := r.Parent(); p != nil {
		if ca := p.CanonicalAction(); ca != nil {
			if routes := ca.Routes; len(routes) > 0 {
				// Note: all these tests should be true at code generation time
				// as DSL validation makes sure that parent resources have a
				// canonical path.
				basePath = path.Join(routes[0].FullPath())
			}
		}
	} else {
		basePath = Design.BasePath
	}
	return httppath.Clean(path.Join(basePath, r.BasePath))
}
722452
func splitPath(path string) []string {
	if path[0] == '/' {
		path = path[1:]
	}
	// Count parts to avoid growing slice.
	var n uint16
	for i := 0; i < len(path); i++ {
		n++
		p := strings.IndexByte(path[i:], '/')
		if p == -1 {
			break
		}
		if p == len(path)-1 { // Also count trailing slash.
			n++
		}
		i = p + i
	}
	s := make([]string, 0, n)
	for {
		p := strings.IndexByte(path, '/')
		if p == -1 {
			s = append(s, path)
			break
		}
		s = append(s, path[:p])
		path = path[p+1:]
	}
	return s
}
563642
func (s ScriptSort) NestedPath(nestedPath string) ScriptSort {
	s.nestedPath = &nestedPath
	return s
}
26764
func splitPath(path, separator string) []string {
	return stringex.SplitFilter(path, separator, func(part string) bool {
		return part != ""
	})
}
741655
func RemoteParserPath(parserName string) string {
	return filepath.Join(runtime.GOOS, runtime.GOARCH, parserName+archExt)
}
646506
func (w *WebService) Path(root string) *WebService {
	w.rootPath = root
	if len(w.rootPath) == 0 {
		w.rootPath = "/"
	}
	w.compilePathExpression()
	return w
}
274994
func resolvePath(base, ref string) string {
	var full string
	if ref == "" {
		full = base
	} else if ref[0] != '/' {
		i := strings.LastIndex(base, "/")
		full = base[:i+1] + ref
	} else {
		full = ref
	}
	if full == "" {
		return ""
	}
	var dst []string
	src := strings.Split(full, "/")
	for _, elem := range src {
		switch elem {
		case ".":
			// drop
		case "..":
			if len(dst) > 0 {
				dst = dst[:len(dst)-1]
			}
		default:
			dst = append(dst, elem)
		}
	}
	if last := src[len(src)-1]; last == "." || last == ".." {
		// Add final slash to the joined path.
		dst = append(dst, "")
	}
	return "/" + strings.TrimLeft(strings.Join(dst, "/"), "/")
}
1355920
func parsePathSpec(path string) (*PathSpec, error) {
	parts := strings.SplitN(path, ":", 2)
	if !isPathForPod(path) {
		return &PathSpec{
			Path: path,
		}, nil
	}
	if reasons := kvalidation.ValidatePodName(parts[0], false); len(reasons) != 0 {
		return nil, fmt.Errorf("invalid pod name %s: %s", parts[0], strings.Join(reasons, ", "))
	}
	return &PathSpec{
		PodName: parts[0],
		Path:    parts[1],
	}, nil
}
602848
func MustParsePath(s string) Path {
	path, ok := ParsePath(s)
	if !ok {
		panic(s)
	}
	return path
}
566189
func GOPath(repourl string) (w string) {
	var e []string
	repourl = FullGOPath(repourl)
	if e = strings.Split(repourl, "/"); len(e) < 3 {
		return ""
	}
	return e[0] + "/" + e[1] + "/" + e[2]
}
406517
func (u *URI) ResolveFilePath(p string) string {
	return cleanPath(path.Join(u.FilePath(), strings.TrimPrefix(p, "/")))
}
414948
func (p *Pod) Stage1RootfsPath() (string, error) {
	stage1RootfsPath := "stage1/rootfs"
	if p.UsesOverlay() {
		stage1TreeStoreID, err := p.GetStage1TreeStoreID()
		if err != nil {
			return "", err
		}
		stage1RootfsPath = fmt.Sprintf("overlay/%s/upper/", stage1TreeStoreID)
	}

	return filepath.Join(p.Path(), stage1RootfsPath), nil
}
786627
func (p *parser) parseLocationPath(n node) (opnd node) {
	switch p.r.typ {
	case itemSlash:
		p.next()
		opnd = newRootNode("/")
		if isStep(p.r.typ) {
			opnd = p.parseRelativeLocationPath(opnd) // ?? child:: or self ??
		}
	case itemSlashSlash:
		p.next()
		opnd = newRootNode("//")
		opnd = p.parseRelativeLocationPath(newAxisNode("descendant-or-self", "", "", "", opnd))
	default:
		opnd = p.parseRelativeLocationPath(n)
	}
	return opnd
}