pkg, clientv3: etcdctl snaprestore when data-dir empty (#11648)

This commit is contained in:
zhanwang
2020-04-05 05:41:19 +08:00
committed by GitHub
parent dbcf540c88
commit 2092b5b1a9
3 changed files with 33 additions and 2 deletions

View File

@ -76,6 +76,12 @@ func Exist(name string) bool {
return err == nil
}
// DirEmpty returns true if a directory empty and can access.
func DirEmpty(name string) bool {
ns, err := ReadDir(name)
return len(ns) == 0 && err == nil
}
// ZeroToEnd zeros a file starting from SEEK_CUR to its SEEK_END. May temporarily
// shorten the length of the file.
func ZeroToEnd(f *os.File) error {