mirror of
https://github.com/projectdiscovery/httpx
synced 2026-06-08 16:50:17 +00:00
25 lines
440 B
Go
25 lines
440 B
Go
package fileutil
|
|
|
|
import "os"
|
|
|
|
// FileExists checks if a file exists and is not a directory
|
|
func FileExists(filename string) bool {
|
|
info, err := os.Stat(filename)
|
|
if os.IsNotExist(err) {
|
|
return false
|
|
}
|
|
return !info.IsDir()
|
|
}
|
|
|
|
// HasStdin determines if the user has piped input
|
|
func HasStdin() bool {
|
|
fi, err := os.Stdin.Stat()
|
|
if err != nil {
|
|
return false
|
|
}
|
|
if fi.Mode()&os.ModeNamedPipe == 0 {
|
|
return false
|
|
}
|
|
return true
|
|
}
|