mirror of
https://github.com/axllent/mailpit.git
synced 2026-06-27 22:46:09 +00:00
27 lines
519 B
Go
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
|
|
}
|