github.com/rita33cool1/iot-system-gateway@v0.0.0-20200911033302-e65bde238cc5/docker-engine/builder/dockerfile/dispatchers_unix.go (about)

     1  // +build !windows
     2  
     3  package dockerfile // import "github.com/docker/docker/builder/dockerfile"
     4  
     5  import (
     6  	"errors"
     7  	"os"
     8  	"path/filepath"
     9  )
    10  
    11  // normalizeWorkdir normalizes a user requested working directory in a
    12  // platform semantically consistent way.
    13  func normalizeWorkdir(_ string, current string, requested string) (string, error) {
    14  	if requested == "" {
    15  		return "", errors.New("cannot normalize nothing")
    16  	}
    17  	current = filepath.FromSlash(current)
    18  	requested = filepath.FromSlash(requested)
    19  	if !filepath.IsAbs(requested) {
    20  		return filepath.Join(string(os.PathSeparator), current, requested), nil
    21  	}
    22  	return requested, nil
    23  }