Explorar o código

Merge pull request #12980 from Microsoft/10662-filepathimageimage

Windows: Fix filepath vs path in image.go
Alexander Morozov %!s(int64=10) %!d(string=hai) anos
pai
achega
f65e65b0c9
Modificáronse 1 ficheiros con 6 adicións e 6 borrados
  1. 6 6
      image/image.go

+ 6 - 6
image/image.go

@@ -5,7 +5,7 @@ import (
 	"fmt"
 	"fmt"
 	"io/ioutil"
 	"io/ioutil"
 	"os"
 	"os"
-	"path"
+	"path/filepath"
 	"regexp"
 	"regexp"
 	"strconv"
 	"strconv"
 	"time"
 	"time"
@@ -55,7 +55,7 @@ func LoadImage(root string) (*Image, error) {
 		return nil, err
 		return nil, err
 	}
 	}
 
 
-	if buf, err := ioutil.ReadFile(path.Join(root, "layersize")); err != nil {
+	if buf, err := ioutil.ReadFile(filepath.Join(root, "layersize")); err != nil {
 		if !os.IsNotExist(err) {
 		if !os.IsNotExist(err) {
 			return nil, err
 			return nil, err
 		}
 		}
@@ -107,21 +107,21 @@ func (img *Image) SetGraph(graph Graph) {
 
 
 // SaveSize stores the current `size` value of `img` in the directory `root`.
 // SaveSize stores the current `size` value of `img` in the directory `root`.
 func (img *Image) SaveSize(root string) error {
 func (img *Image) SaveSize(root string) error {
-	if err := ioutil.WriteFile(path.Join(root, "layersize"), []byte(strconv.Itoa(int(img.Size))), 0600); err != nil {
+	if err := ioutil.WriteFile(filepath.Join(root, "layersize"), []byte(strconv.Itoa(int(img.Size))), 0600); err != nil {
 		return fmt.Errorf("Error storing image size in %s/layersize: %s", root, err)
 		return fmt.Errorf("Error storing image size in %s/layersize: %s", root, err)
 	}
 	}
 	return nil
 	return nil
 }
 }
 
 
 func (img *Image) SaveCheckSum(root, checksum string) error {
 func (img *Image) SaveCheckSum(root, checksum string) error {
-	if err := ioutil.WriteFile(path.Join(root, "checksum"), []byte(checksum), 0600); err != nil {
+	if err := ioutil.WriteFile(filepath.Join(root, "checksum"), []byte(checksum), 0600); err != nil {
 		return fmt.Errorf("Error storing checksum in %s/checksum: %s", root, err)
 		return fmt.Errorf("Error storing checksum in %s/checksum: %s", root, err)
 	}
 	}
 	return nil
 	return nil
 }
 }
 
 
 func (img *Image) GetCheckSum(root string) (string, error) {
 func (img *Image) GetCheckSum(root string) (string, error) {
-	cs, err := ioutil.ReadFile(path.Join(root, "checksum"))
+	cs, err := ioutil.ReadFile(filepath.Join(root, "checksum"))
 	if err != nil {
 	if err != nil {
 		if os.IsNotExist(err) {
 		if os.IsNotExist(err) {
 			return "", nil
 			return "", nil
@@ -132,7 +132,7 @@ func (img *Image) GetCheckSum(root string) (string, error) {
 }
 }
 
 
 func jsonPath(root string) string {
 func jsonPath(root string) string {
-	return path.Join(root, "json")
+	return filepath.Join(root, "json")
 }
 }
 
 
 func (img *Image) RawJson() ([]byte, error) {
 func (img *Image) RawJson() ([]byte, error) {