Skip to content

Commit

Permalink
Modified fs util functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Priya Wadhwa committed Mar 19, 2018
1 parent de8cc1a commit 93e1595
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions pkg/util/fs_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/containers/image/docker"
"github.com/sirupsen/logrus"
"io"
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -120,7 +121,7 @@ func RelativeFiles(fp string, root string) ([]string, error) {
// FilepathExists returns true if the path exists
func FilepathExists(path string) bool {
_, err := os.Stat(path)
return (err == nil)
return !os.IsNotExist(err)
}

// CreateFile creates a file at path with contents specified
Expand All @@ -133,15 +134,5 @@ func CreateFile(path string, contents []byte, perm os.FileMode) error {
return err
}
}

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)
return ioutil.WriteFile(path, contents, perm)
}

0 comments on commit 93e1595

Please sign in to comment.