path.go 877 B

1234567891011121314151617181920
  1. package archive
  2. // CheckSystemDriveAndRemoveDriveLetter verifies that a path, if it includes a drive letter,
  3. // is the system drive.
  4. // On Linux: this is a no-op.
  5. // On Windows: this does the following>
  6. // CheckSystemDriveAndRemoveDriveLetter verifies and manipulates a Windows path.
  7. // This is used, for example, when validating a user provided path in docker cp.
  8. // If a drive letter is supplied, it must be the system drive. The drive letter
  9. // is always removed. Also, it translates it to OS semantics (IOW / to \). We
  10. // need the path in this syntax so that it can ultimately be concatenated with
  11. // a Windows long-path which doesn't support drive-letters. Examples:
  12. // C: --> Fail
  13. // C:\ --> \
  14. // a --> a
  15. // /a --> \a
  16. // d:\ --> Fail
  17. func CheckSystemDriveAndRemoveDriveLetter(path string) (string, error) {
  18. return checkSystemDriveAndRemoveDriveLetter(path)
  19. }