Files
mailpit/internal/tools/fs.go
Ralph Slooten 8041eac509 Cleanup
2026-05-14 16:23:29 +12:00

27 lines
519 B
Go

package tools
import (
"os"
)
// IsFile returns whether a path exists and is a regular file.
// Symlinks are deliberately rejected to prevent following links to
// arbitrary files outside the intended location.
func IsFile(path string) bool {
info, err := os.Lstat(path)
if err != nil {
return false
}
return info.Mode().IsRegular()
}
// IsDir returns whether a path is a directory
func IsDir(path string) bool {
info, err := os.Stat(path)
if err != nil || !info.IsDir() {
return false
}
return true
}