Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
libmachine: move copy file function where it is used, in the driver
- Loading branch information
1 parent
3283d45
commit f91a0d6
Showing
4 changed files
with
36 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package hyperv | ||
|
||
import ( | ||
"io" | ||
"os" | ||
) | ||
|
||
func copyFile(src, dst string) error { | ||
in, err := os.Open(src) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
defer in.Close() | ||
|
||
out, err := os.Create(dst) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
defer out.Close() | ||
|
||
if _, err = io.Copy(out, in); err != nil { | ||
return err | ||
} | ||
|
||
fi, err := os.Stat(src) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return os.Chmod(dst, fi.Mode()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters