You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2016/10/11 06:40:01 UTC

[2/5] incubator-mynewt-newt git commit: newt - revendor

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/21deb707/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 2cda3e8..3ecf400 100644
--- a/newt/vendor/mynewt.apache.org/newt/util/util.go
+++ b/newt/vendor/mynewt.apache.org/newt/util/util.go
@@ -363,12 +363,17 @@ func CopyFile(srcFile string, dstFile string) error {
 	}
 	defer in.Close()
 
+	info, err := in.Stat()
+	if err != nil {
+		return ChildNewtError(err)
+	}
+
 	dstDir := filepath.Dir(dstFile)
 	if err := os.MkdirAll(dstDir, os.ModePerm); err != nil {
 		return ChildNewtError(err)
 	}
 
-	out, err := os.Create(dstFile)
+	out, err := os.OpenFile(dstFile, os.O_CREATE|os.O_WRONLY, info.Mode())
 	if err != nil {
 		return ChildNewtError(err)
 	}
@@ -394,7 +399,12 @@ func CopyDir(srcDirStr, dstDirStr string) error {
 		return ChildNewtError(err)
 	}
 
-	if err := os.MkdirAll(filepath.Dir(dstDirStr), os.ModePerm); err != nil {
+	info, err := srcDir.Stat()
+	if err != nil {
+		return ChildNewtError(err)
+	}
+
+	if err := os.MkdirAll(filepath.Dir(dstDirStr), info.Mode()); err != nil {
 		return ChildNewtError(err)
 	}