diff options
author | tjpcc <tjp@ctrl-c.club> | 2023-01-09 16:40:24 -0700 |
---|---|---|
committer | tjpcc <tjp@ctrl-c.club> | 2023-01-09 16:40:24 -0700 |
commit | ff05d62013906f3086b452bfeda3e0d5b9b7a541 (patch) | |
tree | 3be29de0b1bc7c273041c6d89b71ca447c940556 /contrib/fs/stat.go |
Initial commit.
some basics:
- minimal README
- some TODOs
- server and request handler framework
- contribs: file serving, request logging
- server examples
- CI setup
Diffstat (limited to 'contrib/fs/stat.go')
-rw-r--r-- | contrib/fs/stat.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/contrib/fs/stat.go b/contrib/fs/stat.go new file mode 100644 index 0000000..4dd65d8 --- /dev/null +++ b/contrib/fs/stat.go @@ -0,0 +1,28 @@ +package fs + +import ( + "errors" + "io/fs" +) + +func isNotFound(err error) bool { + if err == nil { + return false + } + + var pathErr *fs.PathError + if errors.As(err, &pathErr) { + e := pathErr.Err + return errors.Is(e, fs.ErrInvalid) || errors.Is(e, fs.ErrNotExist) + } + + return false +} + +func fileIsDir(file fs.File) (bool, error) { + info, err := file.Stat() + if err != nil { + return false, err + } + return info.IsDir(), nil +} |