github.com/moby/docker@v26.1.3+incompatible/pkg/archive/path_windows.go (about)

     1  package archive
     2  
     3  import (
     4  	"fmt"
     5  	"path/filepath"
     6  	"strings"
     7  )
     8  
     9  // checkSystemDriveAndRemoveDriveLetter is the Windows implementation
    10  // of CheckSystemDriveAndRemoveDriveLetter
    11  func checkSystemDriveAndRemoveDriveLetter(path string) (string, error) {
    12  	if len(path) == 2 && string(path[1]) == ":" {
    13  		return "", fmt.Errorf("no relative path specified in %q", path)
    14  	}
    15  	if !filepath.IsAbs(path) || len(path) < 2 {
    16  		return filepath.FromSlash(path), nil
    17  	}
    18  	if string(path[1]) == ":" && !strings.EqualFold(string(path[0]), "c") {
    19  		return "", fmt.Errorf("the specified path is not on the system drive (C:)")
    20  	}
    21  	return filepath.FromSlash(path[2:]), nil
    22  }