mirror of
https://github.com/schollz/croc.git
synced 2025-10-11 13:21:00 +02:00
fix: prompt for overwriting when unzipping
This commit is contained in:
parent
13bc190f8b
commit
b3668a6f5c
1 changed files with 10 additions and 0 deletions
|
@ -447,6 +447,16 @@ func UnzipDirectory(destination string, source string) error {
|
||||||
log.Fatalln(err)
|
log.Fatalln(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check if file exists
|
||||||
|
if _, err := os.Stat(filePath); err == nil {
|
||||||
|
prompt := fmt.Sprintf("\nOverwrite '%s'? (y/N) ", filePath)
|
||||||
|
choice := strings.ToLower(GetInput(prompt))
|
||||||
|
if choice != "y" && choice != "yes" {
|
||||||
|
fmt.Fprintf(os.Stderr, "skipping '%s'", filePath)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
dstFile, err := os.OpenFile(filePath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, f.Mode())
|
dstFile, err := os.OpenFile(filePath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, f.Mode())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalln(err)
|
log.Fatalln(err)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue