From 85056def909c994b66c40763f6d6c2d41c7a61d0 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sun, 1 Apr 2018 12:31:44 +0200 Subject: main: move and rename checkDir*() helper To avoid confusion with fsck, rename to isDir*() and move the functions into init_dir.go. --- checkdir.go | 36 ------------------------------------ 1 file changed, 36 deletions(-) delete mode 100644 checkdir.go (limited to 'checkdir.go') diff --git a/checkdir.go b/checkdir.go deleted file mode 100644 index 63dfef0..0000000 --- a/checkdir.go +++ /dev/null @@ -1,36 +0,0 @@ -package main - -import ( - "fmt" - "io/ioutil" - "os" -) - -// checkDirEmpty - check if "dir" exists and is an empty directory. -// Returns an *os.PathError if Stat() on the path fails. -func checkDirEmpty(dir string) error { - err := checkDir(dir) - if err != nil { - return err - } - entries, err := ioutil.ReadDir(dir) - if err != nil { - return err - } - if len(entries) == 0 { - return nil - } - return fmt.Errorf("directory %s not empty", dir) -} - -// checkDir - check if "dir" exists and is a directory -func checkDir(dir string) error { - fi, err := os.Stat(dir) - if err != nil { - return err - } - if !fi.IsDir() { - return fmt.Errorf("%s is not a directory", dir) - } - return nil -} -- cgit v1.2.3