mynewt-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ccoll...@apache.org
Subject [22/50] incubator-mynewt-newt git commit: newt - remove extra broken CopyFile function.
Date Thu, 10 Nov 2016 22:38:34 GMT
newt - remove extra broken CopyFile function.

There were two CopyFile functions (newtutil. and util.).  util.CopyFile
was somewhat broken as it did not truncate the destination.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/e2e7083f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/e2e7083f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/e2e7083f

Branch: refs/heads/master
Commit: e2e7083f6dc08152af6a45180e3423e3d10b5599
Parents: f04edf5
Author: Christopher Collins <ccollins@apache.org>
Authored: Mon Oct 31 18:03:55 2016 -0700
Committer: Christopher Collins <ccollins@apache.org>
Committed: Mon Oct 31 18:03:55 2016 -0700

----------------------------------------------------------------------
 newt/newtutil/newtutil.go                       | 24 --------------------
 newt/vendor/mynewt.apache.org/newt/util/util.go | 10 ++------
 util/util.go                                    |  3 ++-
 3 files changed, 4 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e2e7083f/newt/newtutil/newtutil.go
----------------------------------------------------------------------
diff --git a/newt/newtutil/newtutil.go b/newt/newtutil/newtutil.go
index 2f52052..af949f0 100644
--- a/newt/newtutil/newtutil.go
+++ b/newt/newtutil/newtutil.go
@@ -21,8 +21,6 @@ package newtutil
 
 import (
 	"fmt"
-	"io"
-	"os"
 	"os/user"
 	"sort"
 	"strconv"
@@ -207,28 +205,6 @@ func BuildPackageString(repoName string, pkgName string) string {
 	}
 }
 
-func CopyFile(dst string, src string) error {
-	// open files r and w
-	r, err := os.Open(src)
-	if err != nil {
-		return err
-	}
-	defer r.Close()
-
-	w, err := os.Create(dst)
-	if err != nil {
-		return err
-	}
-	defer w.Close()
-
-	// do the actual work
-	_, err = io.Copy(w, r)
-	if err != nil {
-		return err
-	}
-	return nil
-}
-
 func GeneratedPreamble() string {
 	return fmt.Sprintf("/**\n * This file was generated by %s\n */\n\n",
 		NewtVersionStr)

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e2e7083f/newt/vendor/mynewt.apache.org/newt/util/util.go
----------------------------------------------------------------------
diff --git a/newt/vendor/mynewt.apache.org/newt/util/util.go b/newt/vendor/mynewt.apache.org/newt/util/util.go
index fd79c1b..d43f709 100644
--- a/newt/vendor/mynewt.apache.org/newt/util/util.go
+++ b/newt/vendor/mynewt.apache.org/newt/util/util.go
@@ -373,7 +373,8 @@ func CopyFile(srcFile string, dstFile string) error {
 		return ChildNewtError(err)
 	}
 
-	out, err := os.OpenFile(dstFile, os.O_CREATE|os.O_WRONLY, info.Mode())
+	out, err := os.OpenFile(dstFile, os.O_CREATE|os.O_WRONLY|os.O_TRUNC,
+		info.Mode())
 	if err != nil {
 		return ChildNewtError(err)
 	}
@@ -383,13 +384,6 @@ func CopyFile(srcFile string, dstFile string) error {
 		return ChildNewtError(err)
 	}
 
-	if err := in.Close(); err != nil {
-		return err
-	}
-	if err := out.Close(); err != nil {
-		return err
-	}
-
 	return nil
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e2e7083f/util/util.go
----------------------------------------------------------------------
diff --git a/util/util.go b/util/util.go
index fd79c1b..56cb5c0 100644
--- a/util/util.go
+++ b/util/util.go
@@ -373,7 +373,8 @@ func CopyFile(srcFile string, dstFile string) error {
 		return ChildNewtError(err)
 	}
 
-	out, err := os.OpenFile(dstFile, os.O_CREATE|os.O_WRONLY, info.Mode())
+	out, err := os.OpenFile(dstFile, os.O_CREATE|os.O_WRONLY|os.O_TRUNC,
+		info.Mode())
 	if err != nil {
 		return ChildNewtError(err)
 	}


Mime
View raw message