Skip to content

Commit

Permalink
Put copyFile in its own package so I will not be seduced to write it yet
Browse files Browse the repository at this point in the history
again
  • Loading branch information
zimmski committed Jan 3, 2015
1 parent 25cc3ce commit 2b3c8e6
Showing 1 changed file with 2 additions and 37 deletions.
39 changes: 2 additions & 37 deletions cmd/go-mutesting/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (

"github.com/jessevdk/go-flags"
"github.com/zimmski/go-tool/importing"
"github.com/zimmski/osutil"

"github.com/zimmski/go-mutesting"
"github.com/zimmski/go-mutesting/mutator"
Expand Down Expand Up @@ -233,7 +234,7 @@ MUTATOR:
tmpFile := tmpDir + "/" + file

originalFile := fmt.Sprintf("%s.original", tmpFile)
err = copyFile(file, originalFile)
err = osutil.CopyFile(file, originalFile)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -352,42 +353,6 @@ func main() {
os.Exit(mainCmd(os.Args[1:]))
}

func copyFile(src string, dst string) (err error) {
s, err := os.Open(src)
if err != nil {
return err
}
defer func() {
e := s.Close()
if err == nil {
err = e
}
}()

d, err := os.Create(dst)
if err != nil {
return err
}
defer func() {
e := d.Close()
if err == nil {
err = e
}
}()

_, err = io.Copy(d, s)
if err == nil {
i, err := os.Stat(src)
if err != nil {
return err
}

return os.Chmod(dst, i.Mode())
}

return nil
}

func saveAST(mutationBlackList map[string]struct{}, file string, fset *token.FileSet, node ast.Node) (string, bool, error) {
var buf bytes.Buffer

Expand Down

0 comments on commit 2b3c8e6

Please sign in to comment.