-
Notifications
You must be signed in to change notification settings - Fork 23
Add our own copy.exe binary so that we can copy without cmd.exe #65
Conversation
|
||
// Make sure there are only two arguments | ||
if len(args) != 2 { | ||
log.Fatal("copy.exe <source> <destination>") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use os.Args[0]
instead of hardcoding copy.exe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call. It's not even called copy.exe
anymore.
|
||
func exit_if_error(err error) { | ||
if err != nil { | ||
log.Fatal("ERROR:", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any particular reason for using log.* functions for errors, instead of just fmt.Printf
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log.Fatal
is fmt.Print
followed by os.Exit(1)
https://golang.org/pkg/log/#Fatal
defer source_file.Close() | ||
|
||
// Make sure we can create the destination file | ||
destination_file, err := os.Create(destination_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you're creating an empty version of the dest. file in order to check if you can access that path? is there a cleaner way to do that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It creates to get a file handle, so that io.Copy()
can use it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, fair enough
a51d864
to
47009e9
Compare
@facchinm and everyone, please test.
At the end of the compilation, you should see this.
The line that starts with the date shows that the copy was successful. |
It works perfectly! Only a couple of suggestions:
Anyway, that's perfectly fine to leave it as is 😄 |
Thanks @facchinm I'll make those changes. I would prefer to keep |
@calvinatintel I haven't tested yet, but let me know when you make those changes and I'll test after |
47009e9
to
d45accc
Compare
d45accc
to
e0c5b8c
Compare
@facchinm What do you think? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested on Windows 7, works well.
in response to arduino/ArduinoCore-arc32#309