File: path.go

package info (click to toggle)
docker-buildx 0.19.3%2Bds1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,852 kB
  • sloc: sh: 318; makefile: 73
file content (30 lines) | stat: -rw-r--r-- 549 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package osutil

import (
	"os"
	"path/filepath"
)

// GetWd retrieves the current working directory.
//
// On Windows, this function will return the long path name
// version of the path.
func GetWd() string {
	wd, _ := os.Getwd()
	if lp, err := GetLongPathName(wd); err == nil {
		return lp
	}
	return wd
}

func IsLocalDir(c string) bool {
	st, err := os.Stat(c)
	return err == nil && st.IsDir()
}

func ToAbs(path string) string {
	if !filepath.IsAbs(path) {
		path, _ = filepath.Abs(filepath.Join(GetWd(), path))
	}
	return SanitizePath(path)
}