Jelajahi Sumber

Merge pull request #11189 from ahmetalpbalkan/win-cli/archive-path-separator

pkg/archive_windows: make use of os.PathSeparator
Doug Davis 10 tahun lalu
induk
melakukan
2a8a2d2428
1 mengubah file dengan 3 tambahan dan 1 penghapusan
  1. 3 1
      pkg/archive/archive_windows.go

+ 3 - 1
pkg/archive/archive_windows.go

@@ -4,6 +4,7 @@ package archive
 
 
 import (
 import (
 	"fmt"
 	"fmt"
+	"os"
 	"strings"
 	"strings"
 
 
 	"github.com/docker/docker/vendor/src/code.google.com/p/go/src/pkg/archive/tar"
 	"github.com/docker/docker/vendor/src/code.google.com/p/go/src/pkg/archive/tar"
@@ -20,7 +21,8 @@ func CanonicalTarNameForPath(p string) (string, error) {
 	if strings.Contains(p, "/") {
 	if strings.Contains(p, "/") {
 		return "", fmt.Errorf("windows path contains forward slash: %s", p)
 		return "", fmt.Errorf("windows path contains forward slash: %s", p)
 	}
 	}
-	return strings.Replace(p, "\\", "/", -1), nil
+	return strings.Replace(p, string(os.PathSeparator), "/", -1), nil
+
 }
 }
 
 
 func setHeaderForSpecialDevice(hdr *tar.Header, ta *tarAppender, name string, stat interface{}) (nlink uint32, inode uint64, err error) {
 func setHeaderForSpecialDevice(hdr *tar.Header, ta *tarAppender, name string, stat interface{}) (nlink uint32, inode uint64, err error) {