Modified fs util functions
This commit is contained in:
parent
de8cc1a285
commit
f4e9eeb15a
|
|
@ -82,9 +82,6 @@ func (c *CopyCommand) ExecuteCommand(config *manifest.Schema2Config) error {
|
||||||
|
|
||||||
// FilesToSnapshot should return an empty array if still nil; no files were changed
|
// FilesToSnapshot should return an empty array if still nil; no files were changed
|
||||||
func (c *CopyCommand) FilesToSnapshot() []string {
|
func (c *CopyCommand) FilesToSnapshot() []string {
|
||||||
if c.snapshotFiles == nil {
|
|
||||||
return []string{}
|
|
||||||
}
|
|
||||||
return c.snapshotFiles
|
return c.snapshotFiles
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ import (
|
||||||
"github.com/containers/image/docker"
|
"github.com/containers/image/docker"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"io"
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
@ -120,7 +121,7 @@ func RelativeFiles(fp string, root string) ([]string, error) {
|
||||||
// FilepathExists returns true if the path exists
|
// FilepathExists returns true if the path exists
|
||||||
func FilepathExists(path string) bool {
|
func FilepathExists(path string) bool {
|
||||||
_, err := os.Stat(path)
|
_, err := os.Stat(path)
|
||||||
return (err == nil)
|
return !os.IsNotExist(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateFile creates a file at path with contents specified
|
// CreateFile creates a file at path with contents specified
|
||||||
|
|
@ -133,15 +134,5 @@ func CreateFile(path string, contents []byte, perm os.FileMode) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return ioutil.WriteFile(path, contents, perm)
|
||||||
f, err := os.Create(path)
|
|
||||||
defer f.Close()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
_, err = f.Write(contents)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return f.Chmod(perm)
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue