1
0
mirror of https://github.com/byReqz/go-etcher.git synced 2024-11-22 15:01:16 +00:00

show file sizes at confirmation dialog

This commit is contained in:
Nils 2022-01-13 23:53:39 +01:00
parent 37348c71aa
commit 9cb93fa170
Signed by: byreqz
GPG Key ID: 396A62D7D436749E

15
main.go
View File

@ -131,7 +131,8 @@ func main() {
s.Prefix = "[ " s.Prefix = "[ "
s.Suffix = " ] Getting file details" s.Suffix = " ] Getting file details"
s.Start() s.Start()
stat, err := os.Stat(input) statinput, err := os.Stat(input)
statdevice, err := os.Stat(device)
if err != nil { if err != nil {
s.Stop() s.Stop()
fmt.Println("\r[", color.RedString("✘"), "] Getting file details ") fmt.Println("\r[", color.RedString("✘"), "] Getting file details ")
@ -159,9 +160,13 @@ func main() {
s.Stop() s.Stop()
fmt.Println("\r[", color.GreenString("✓"), "] Opening files ") fmt.Println("\r[", color.GreenString("✓"), "] Opening files ")
} }
inputmb := fmt.Sprint("[", statinput.Size() / 1024 / 1024, "MB]")
fmt.Println("[", color.BlueString("i"), "] Input device/file:", input) devicemb := fmt.Sprint("[", statdevice.Size() / 1024 / 1024, "MB]")
fmt.Println("[", color.BlueString("i"), "] Output device/file:", device) fmt.Println("[", color.BlueString("i"), "] Input device/file: " + input, inputmb)
fmt.Println("[", color.BlueString("i"), "] Output device/file: " + device, devicemb)
if statinput.Size() > statdevice.Size() {
fmt.Println("[", color.RedString("w"), "]", color.RedString(" Warning:"), "Input file seems to be bigger than the destination!")
}
fmt.Print(color.HiWhiteString("Do you want to continue? [y/N]: ")) fmt.Print(color.HiWhiteString("Do you want to continue? [y/N]: "))
var yesno string var yesno string
_, _ = fmt.Scanln(&yesno) _, _ = fmt.Scanln(&yesno)
@ -170,7 +175,7 @@ func main() {
log.Fatal("aborted") log.Fatal("aborted")
} }
written, err := WriteImage(image, target, stat.Size()) written, err := WriteImage(image, target, statinput.Size())
if err != nil { if err != nil {
fmt.Println("\r[", color.RedString("✘"), "] Writing image,", written, "bytes written ") fmt.Println("\r[", color.RedString("✘"), "] Writing image,", written, "bytes written ")
log.Fatal(err) log.Fatal(err)