mirror of
https://github.com/maaslalani/slides.git
synced 2026-01-08 22:07:59 -05:00
25 lines
485 B
Go
25 lines
485 B
Go
// Package file includes utility functions
|
|
// for working with the filesystem
|
|
package file
|
|
|
|
import (
|
|
"io/fs"
|
|
"os"
|
|
)
|
|
|
|
// Exists is a helper to verify
|
|
// that the provided filepath exists
|
|
// on the system
|
|
func Exists(filepath string) bool {
|
|
info, err := os.Stat(filepath)
|
|
if os.IsNotExist(err) {
|
|
return false
|
|
}
|
|
return !info.IsDir()
|
|
}
|
|
|
|
// IsExecutable returns whether a file has execution permissions
|
|
func IsExecutable(s fs.FileInfo) bool {
|
|
return s.Mode().Perm()&0111 == 0111
|
|
}
|