github.com/Prakhar-Agarwal-byte/moby@v0.0.0-20231027092010-a14e3e8ab87e/pkg/system/filesys.go (about) 1 package system 2 3 import ( 4 "os" 5 "path/filepath" 6 "strings" 7 ) 8 9 // IsAbs is a platform-agnostic wrapper for filepath.IsAbs. 10 // 11 // On Windows, golang filepath.IsAbs does not consider a path \windows\system32 12 // as absolute as it doesn't start with a drive-letter/colon combination. However, 13 // in docker we need to verify things such as WORKDIR /windows/system32 in 14 // a Dockerfile (which gets translated to \windows\system32 when being processed 15 // by the daemon). This SHOULD be treated as absolute from a docker processing 16 // perspective. 17 func IsAbs(path string) bool { 18 return filepath.IsAbs(path) || strings.HasPrefix(path, string(os.PathSeparator)) 19 }