1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Windows: Fix filepath vs path in image.go

Signed-off-by: John Howard <jhoward@microsoft.com>
This commit is contained in:
John Howard 2015-05-04 16:23:17 -07:00
parent 56c9917815
commit 1c3b697d60

View file

@ -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) {