mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-10 13:37:08 +08:00
vendor: github.com/moby/buildkit v0.21.0-rc1
Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
This commit is contained in:
29
vendor/github.com/moby/buildkit/util/system/path_windows.go
generated
vendored
Normal file
29
vendor/github.com/moby/buildkit/util/system/path_windows.go
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// DefaultSystemVolumeName is the default system volume label on Windows
|
||||
const DefaultSystemVolumeName = "C:"
|
||||
|
||||
// IsAbsolutePath prepends the default system volume label
|
||||
// to the path that is presumed absolute, and then calls filepath.IsAbs
|
||||
func IsAbsolutePath(path string) bool {
|
||||
path = filepath.Clean(path)
|
||||
if strings.HasPrefix(path, "\\") {
|
||||
path = DefaultSystemVolumeName + path
|
||||
}
|
||||
return filepath.IsAbs(path)
|
||||
}
|
||||
|
||||
// GetAbsolutePath returns an absolute path rooted
|
||||
// to C:\\ on Windows.
|
||||
func GetAbsolutePath(path string) string {
|
||||
path = filepath.Clean(path)
|
||||
if len(path) >= 2 && strings.EqualFold(path[:2], DefaultSystemVolumeName) {
|
||||
return path
|
||||
}
|
||||
return DefaultSystemVolumeName + path
|
||||
}
|
Reference in New Issue
Block a user