mirror of
https://github.com/byReqz/go-etcher.git
synced 2024-11-22 15:01:16 +00:00
add note about input/target being a blockdev or file
This commit is contained in:
parent
4f6b025642
commit
03290ddc09
37
main.go
37
main.go
@ -132,6 +132,11 @@ func main() {
|
|||||||
s.Suffix = " ] Getting file details"
|
s.Suffix = " ] Getting file details"
|
||||||
s.Start()
|
s.Start()
|
||||||
statinput, err := os.Stat(input)
|
statinput, err := os.Stat(input)
|
||||||
|
if err != nil {
|
||||||
|
s.Stop()
|
||||||
|
fmt.Println("\r[", color.RedString("✘"), "] Getting file details ")
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
statdevice, err := os.Stat(device)
|
statdevice, err := os.Stat(device)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.Stop()
|
s.Stop()
|
||||||
@ -146,18 +151,34 @@ func main() {
|
|||||||
s.Suffix = " ] Opening files"
|
s.Suffix = " ] Opening files"
|
||||||
s.Start()
|
s.Start()
|
||||||
image, err := os.Open(input)
|
image, err := os.Open(input)
|
||||||
|
if err != nil {
|
||||||
|
s.Stop()
|
||||||
|
fmt.Println("\r[", color.RedString("✘"), "] Opening files ")
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
var inputsize int64
|
var inputsize int64
|
||||||
|
var inputisblock bool
|
||||||
if statinput.Size() != 0 {
|
if statinput.Size() != 0 {
|
||||||
inputsize = statinput.Size()
|
inputsize = statinput.Size()
|
||||||
|
inputisblock = false
|
||||||
} else {
|
} else {
|
||||||
inputsize, err = image.Seek(0, io.SeekEnd)
|
inputsize, err = image.Seek(0, io.SeekEnd)
|
||||||
|
inputisblock = true
|
||||||
}
|
}
|
||||||
target, err := os.OpenFile(device, os.O_RDWR, 0660)
|
target, err := os.OpenFile(device, os.O_RDWR, 0660)
|
||||||
|
if err != nil {
|
||||||
|
s.Stop()
|
||||||
|
fmt.Println("\r[", color.RedString("✘"), "] Opening files ")
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
var targetsize int64
|
var targetsize int64
|
||||||
|
var targetisblock bool
|
||||||
if statdevice.Size() != 0 {
|
if statdevice.Size() != 0 {
|
||||||
targetsize = statdevice.Size()
|
targetsize = statdevice.Size()
|
||||||
|
targetisblock = false
|
||||||
} else {
|
} else {
|
||||||
targetsize, err = target.Seek(0, io.SeekEnd)
|
targetsize, err = target.Seek(0, io.SeekEnd)
|
||||||
|
targetisblock = true
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.Stop()
|
s.Stop()
|
||||||
@ -169,8 +190,20 @@ func main() {
|
|||||||
}
|
}
|
||||||
inputmb := fmt.Sprint("[", inputsize / 1024 / 1024, "MB]")
|
inputmb := fmt.Sprint("[", inputsize / 1024 / 1024, "MB]")
|
||||||
devicemb := fmt.Sprint("[", targetsize / 1024 / 1024, "MB]")
|
devicemb := fmt.Sprint("[", targetsize / 1024 / 1024, "MB]")
|
||||||
fmt.Println("[", color.BlueString("i"), "] Input device/file: " + input, inputmb)
|
var inputblock string
|
||||||
fmt.Println("[", color.BlueString("i"), "] Output device/file: " + device, devicemb)
|
var targetblock string
|
||||||
|
if inputisblock == true {
|
||||||
|
inputblock = "[Blockdevice]"
|
||||||
|
} else {
|
||||||
|
inputblock = "[File]"
|
||||||
|
}
|
||||||
|
if targetisblock == true {
|
||||||
|
targetblock = "[Blockdevice]"
|
||||||
|
} else {
|
||||||
|
targetblock = "[File]"
|
||||||
|
}
|
||||||
|
fmt.Println("[", color.BlueString("i"), "] Input device/file: " + input, inputmb, inputblock)
|
||||||
|
fmt.Println("[", color.BlueString("i"), "] Output device/file: " + device, devicemb, targetblock)
|
||||||
if statinput.Size() > statdevice.Size() {
|
if statinput.Size() > statdevice.Size() {
|
||||||
fmt.Println("[", color.RedString("w"), "]", color.RedString(" Warning:"), "Input file seems to be bigger than the destination!")
|
fmt.Println("[", color.RedString("w"), "]", color.RedString(" Warning:"), "Input file seems to be bigger than the destination!")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user