filesys.go 654 B

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