ID: fe8a58639f2f1a72c58bf016dcac3fdacc9354c6
24 lines
—
422B —
View raw
| package ws
import (
"fmt"
"os"
)
func checkFile(fileNa string) error {
var (
err error
stat os.FileInfo
)
if stat, err = os.Stat(fileNa); err != nil {
return fmt.Errorf("unable to check metadata for file '%s': %v", fileNa, err)
}
if !stat.Mode().IsRegular() {
return fmt.Errorf("file '%s' is not regular")
}
if stat.Mode()&0444 == 0 {
return fmt.Errorf("file '%s' is not readable")
}
return nil
}
|