// rel returns the relative path to this path.
347508
func (g *Git) rel(path string) (string, error) {
	relPath, err := filepath.Rel(g.base, path)
	if err != nil {
		return "", fmt.Errorf("git cannot make path relative: %v", err)
	}
	return relPath, nil
}
1198217
func Realpath(fpath string) (string, error) {

	if len(fpath) == 0 {
		return "", os.ErrInvalid
	}

	if !filepath.IsAbs(fpath) {
		pwd, err := os.Getwd()
		if err != nil {
			return "", err
		}
		fpath = filepath.Join(pwd, fpath)
	}

	path := []byte(fpath)
	nlinks := 0
	start := 1
	prev := 1
	for start < len(path) {
		c := nextComponent(path, start)
		cur := c[start:]

		switch {

		case len(cur) == 0:
			copy(path[start:], path[start+1:])
			path = path[0 : len(path)-1]

		case len(cur) == 1 && cur[0] == '.':
			if start+2 < len(path) {
				copy(path[start:], path[start+2:])
			}
			path = path[0 : len(path)-2]

		case len(cur) == 2 && cur[0] == '.' && cur[1] == '.':
			copy(path[prev:], path[start+2:])
			path = path[0 : len(path)+prev-(start+2)]
			prev = 1
			start = 1

		default:

			fi, err := os.Lstat(string(c))
			if err != nil {
				return "", err
			}
			if isSymlink(fi) {

				nlinks++
				if nlinks > 16 {
					return "", os.ErrInvalid
				}

				var link string
				link, err = os.Readlink(string(c))
				after := string(path[len(c):])

				// switch symlink component with its real path
				path = switchSymlinkCom(path, start, link, after)

				prev = 1
				start = 1
			} else {
				// Directories
				prev = start
				start = len(c) + 1
			}
		}
	}

	for len(path) > 1 && path[len(path)-1] == os.PathSeparator {
		path = path[0 : len(path)-1]
	}
	return string(path), nil

}
616066
func (e *delayedEnvironment) Bool(key string, def bool) bool {
	e.Load()
	return e.env.Bool(key, def)
}
549243
func (h Relations) Rel(name string, m M) (*url.URL, error) {
	if rel, ok := h[name]; ok {
		return rel.Expand(m)
	}
	return nil, fmt.Errorf("No %s relation found", name)
}
584508
func (z *Dec) Mul(x, y *Dec) *Dec {
	z.SetScale(x.Scale() + y.Scale())
	z.UnscaledBig().Mul(x.UnscaledBig(), y.UnscaledBig())
	return z
}
1130197
func (router *Router) StaticRelative(p string, relativeDir string) *Router {
	// TODO: is this needed?? ;)
	_, f, _, _ := runtime.Caller(1)
	return router.Static(p, path.Join(path.Dir(f), relativeDir))
}
321043
func (d *Dir) MkdirAll(subPath string, filemode os.FileMode) error {
	pathNodes := strings.Split(path.Clean(subPath), "/")
	currentNode := d
	for i, nodeName := range pathNodes {
		newCurrentNode, err := currentNode.GetNode(nodeName)
		if err == nil {
			// get exist path node
			if !newCurrentNode.IsDir() {
				return fmt.Errorf(nodeName + " exists and is not dir in path " + subPath)
			}
			currentNode = newCurrentNode.(*Dir)
			continue
		}
		//create directories
		var subDir *Dir
		for i2 := len(pathNodes) - 1; i2 >= i; i2-- {
			newSubDir := &Dir{
				name:     pathNodes[i2],
				filemode: filemode,
				time:     time.Now(),
				nodes:    []os.FileInfo{},
			}
			if subDir != nil {
				newSubDir.AddNode(subDir)
			}
			subDir = newSubDir
		}
		currentNode.AddNode(subDir)
		return nil
	}
	return nil
}
150779
func (r *Root) Rels() hypermedia.Relations {
	if r.rels == nil || len(r.rels) == 0 {
		r.rels = hypermedia.HyperFieldDecoder(r)
		for key, hyperlink := range r.HALResource.Rels() {
			r.rels[key] = hyperlink
		}
	}
	return r.rels
}
1285623
func (c *DefaultPlanner) ForceFull() {
	c.mu.Lock()
	defer c.mu.Unlock()
	c.forceFull = true
}
211237
func (l *d2) mvL(r *d2, c int) {
	copy(l.d[l.c:], r.d[:c])
	copy(r.d[:], r.d[c:r.c])
	l.c += c
	r.c -= c
}
593273
func (s *File) SetRelativePath(v string) *File {
	s.RelativePath = &v
	return s
}
663656
func ToToml(v interface{}) string {
	b := bytes.NewBuffer(nil)
	e := toml.NewEncoder(b)
	err := e.Encode(v)
	if err != nil {
		return err.Error()
	}
	return b.String()
}
478620
func RelativePath(pathFromRoot string) (relativePath string, err error) {
	task := fmt.Sprintf("Get the relative for '%v'", pathFromRoot)

	root, err := RepositoryRootAbsolutePath()
	if err != nil {
		return "", errs.NewError(task, err)
	}
	absolutePath := filepath.Join(root, pathFromRoot)

	cwd, err := os.Getwd()
	if err != nil {
		return "", errs.NewError(task, err)
	}

	relativePath, err = filepath.Rel(cwd, absolutePath)
	if err != nil {
		return "", errs.NewError(task, err)
	}

	return relativePath, nil
}
841598
func (t *File_Template) RenderL(m LiteralMap) (string, error) {
	pm, err := m.Convert()
	if err != nil {
		return "", err
	}
	return t.Render(pm)
}
980085
func Rels(resource interface{}) Relations {
	cachedResource, ok := resource.(CachedResource)
	if ok {
		if rels, cached := cachedResource.Rels(); cached {
			return rels
		}
	}

	rels := NewRels()
	FillRels(resource, rels)

	if ok {
		cachedResource.CacheRels(rels)
	}

	return rels
}
68001
func Rel(basepath containerfs.ContainerFS, targpath string) (string, error) {
	// filepath.Rel can't handle UUID paths in windows
	if basepath.OS() == "windows" {
		pfx := basepath.Path() + `\`
		if strings.HasPrefix(targpath, pfx) {
			p := strings.TrimPrefix(targpath, pfx)
			if p == "" {
				p = "."
			}
			return p, nil
		}
	}
	return basepath.Rel(basepath.Path(), targpath)
}
1090038
func (s *Folder) SetRelativePath(v string) *Folder {
	s.RelativePath = &v
	return s
}