// BuildCanonicalPathForTlf returns a canonical path for a tlf. Although tlf
// identifies a TLF, paths should still include the TLF name. This function
// does not try to canonicalize TLF names.
17810
func BuildCanonicalPathForTlf(tlf tlf.ID, paths ...string) string {
	return BuildCanonicalPathForTlfType(tlf.Type(), paths...)
}
615479
func (c *Config) LoadConfigFromFilePath(filePath string) (err error) {
	if strings.Index(filePath, "~/") == 0 {
		filePath = strings.Replace(filePath, "~/", getHome()+"/", 1)
	}

	yamlString, err := ioutil.ReadFile(filePath)
	if err != nil {
		logger.Errorf(nil, "File not found: %s.", filePath)
		return err
	}

	return c.LoadConfigFromContent(yamlString)
}
231822
func (extr *ContentExtractor) GetCanonicalLink(document *goquery.Document) string {
	metas := document.Find("link[rel=canonical]")
	if metas.Length() > 0 {
		meta := metas.First()
		href, _ := meta.Attr("href")
		href = strings.Trim(href, "\n")
		href = strings.Trim(href, " ")
		if href != "" {
			return href
		}
	}
	return ""
}
910932
func (c *ConfigLocal) OfflineAvailabilityForPath(
	tlfPath string) keybase1.OfflineAvailability {
	if c.IsSyncedTlfPath(tlfPath) {
		return keybase1.OfflineAvailability_BEST_EFFORT
	}
	return keybase1.OfflineAvailability_NONE
}
466506
func BuildFromPath(path string) (*ServiceTemplate, error) {
	sd, err := servicedefinition.BuildFromPath(path)
	if err != nil {
		return nil, err
	}
	st := ServiceTemplate{
		Services:    []servicedefinition.ServiceDefinition{*sd},
		Name:        sd.Name,
		Version:     sd.Version,
		Description: sd.Description,
	}
	return &st, nil
}
672545
func FuncPath(i interface{}) (pkgName string, objName string, funcName string) {
	s := FuncName(i)
	_, file := path.Split(s)
	return ParseFuncName(file)
}
1102501
func settingsPath(configFolder string) (string, error) {
	seq, err := FindSeqNum(configFolder)
	if err != nil {
		return "", fmt.Errorf("Cannot find seqnum: %v", err)
	}
	return filepath.Join(configFolder, fmt.Sprintf("%d%s", seq, settingsFileSuffix)), nil
}
365984
func ParseTlfTypeFromPath(str string) (Type, error) {
	switch strings.ToLower(str) {
	case strPrivate:
		return Private, nil
	case strPublic:
		return Public, nil
	case strTeam:
		return SingleTeam, nil
	default:
		return Unknown, ErrUnknownTLFType{unknownType: str}
	}
}
631666
func PathLsNType(basePath string, depth int, filetypes []string) (map[int]string, error) {
	return doPathWalk(basePath, depth, filetypes, true)
}
451172
func MakeCanonicalNameForTeam(resolvedWriters []kbname.NormalizedUsername,
	unresolvedWriters []keybase1.SocialAssertion,
	resolvedReaders []kbname.NormalizedUsername,
	unresolvedReaders []keybase1.SocialAssertion,
	extensions []HandleExtension) CanonicalName {
	return makeCanonicalName(
		resolvedWriters, unresolvedWriters, resolvedReaders, unresolvedReaders,
		extensions, true)
}
840995
func (fbo *folderBranchOps) pathFromNodeForRead(n Node) (data.Path, error) {
	return fbo.pathFromNodeHelper(n)
}
708797
func canonicalTarName(name string, isDir bool) (string, error) {
	name, err := CanonicalTarNameForPath(name)
	if err != nil {
		return "", err
	}

	// suffix with '/' for directories
	if isDir && !strings.HasSuffix(name, "/") {
		name += "/"
	}
	return name, nil
}
166211
func blogPath(path, name string) string {
	return fmt.Sprintf(path, normalizeBlogName(name))
}
1312439
func BuildConfigsForTag(g osgraph.Graph, istag graph.Node) []*buildgraph.BuildConfigNode {
	bcs := []*buildgraph.BuildConfigNode{}
	for _, bcNode := range g.PredecessorNodesByEdgeKind(istag, BuildOutputEdgeKind) {
		bcs = append(bcs, bcNode.(*buildgraph.BuildConfigNode))
	}
	return bcs
}
1059541
func remoteTlfAndPath(path keybase1.Path) (
	t tlf.Type, tlfName, middlePath, finalElem string, err error) {
	ps, err := splitPathFromKbfsPath(path)
	if err != nil {
		return tlf.Private, "", "", "", err
	}
	switch {
	case len(ps) < 2:
		return tlf.Private, "", "", "", errInvalidRemotePath
	case ps[0] == `private`:
		t = tlf.Private
	case ps[0] == `public`:
		t = tlf.Public
	case ps[0] == `team`:
		t = tlf.SingleTeam
	default:
		return tlf.Private, "", "", "", errInvalidRemotePath
	}
	if len(ps) >= 3 {
		finalElem = ps[len(ps)-1]
		middlePath = stdpath.Join(ps[2 : len(ps)-1]...)
	}
	return t, ps[1], middlePath, finalElem, nil
}
126069
func (ccpack *SignedCDSPackage) InitFromPath(ccname string, ccversion string, path string) ([]byte, *pb.ChaincodeDeploymentSpec, error) {
	//incase ccpack is reused
	ccpack.reset()

	buf, err := GetChaincodePackageFromPath(ccname, ccversion, path)
	if err != nil {
		return nil, nil, err
	}

	if _, err = ccpack.InitFromBuffer(buf); err != nil {
		return nil, nil, err
	}

	return ccpack.buf, ccpack.depSpec, nil
}
391979
func completeS3Path(s3Path string) (prediction []string) {

	// Convert alias/bucket/incompl to alias/bucket/ to list its contents
	parentDirPath := filepath.Dir(s3Path) + "/"
	clnt, err := newClient(parentDirPath)
	if err != nil {
		return nil
	}

	// Calculate alias from the path
	alias := splitStr(s3Path, "/", 3)[0]

	// List dirPath content and only pick elements that corresponds
	// to the path that we want to complete
	for content := range clnt.List(false, false, DirFirst) {
		completeS3Path := alias + getKey(content)
		if content.Type.IsDir() {
			if !strings.HasSuffix(completeS3Path, "/") {
				completeS3Path += "/"
			}
		}
		if strings.HasPrefix(completeS3Path, s3Path) {
			prediction = append(prediction, completeS3Path)
		}
	}

	// If completion found only one directory, recursively scan it.
	if len(prediction) == 1 && strings.HasSuffix(prediction[0], "/") {
		prediction = append(prediction, completeS3Path(prediction[0])...)
	}

	return
}