mirror of
https://github.com/axllent/mailpit.git
synced 2025-06-17 00:07:54 +02:00
24 lines
414 B
Go
24 lines
414 B
Go
package tools
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
)
|
|
|
|
// IsFile returns whether a file exists and is readable
|
|
func IsFile(path string) bool {
|
|
f, err := os.Open(filepath.Clean(path))
|
|
defer f.Close()
|
|
return err == nil
|
|
}
|
|
|
|
// IsDir returns whether a path is a directory
|
|
func IsDir(path string) bool {
|
|
info, err := os.Stat(path)
|
|
if err != nil || os.IsNotExist(err) || !info.IsDir() {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|