Create copy destination if it doesn't exist.

This commit is contained in:
trading_peter 2022-01-20 20:59:48 +01:00
parent 311339685c
commit 2bd82e1981

18
main.go
View File

@ -2,6 +2,7 @@ package main
import (
"encoding/json"
"errors"
"fmt"
"os"
"os/signal"
@ -143,13 +144,24 @@ func cp(opts options) {
}
func isFile(path string) bool {
stat, _ := os.Stat(path)
stat, err := os.Stat(path)
if errors.Is(err, os.ErrNotExist) {
return false
}
return !stat.IsDir()
}
func isDir(path string) bool {
stat, _ := os.Stat(path)
return stat.IsDir()
stat, err := os.Stat(path)
if errors.Is(err, os.ErrNotExist) {
os.MkdirAll(path, 0755)
return true
}
return err == nil && stat.IsDir()
}
func build(opts options) {