Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.

Commit 24c37f5

Browse files
authored
Merge pull request #634 from davecheney/fixedbugs/632
internal/fs: IsRegular returns an error on any non regular file
2 parents 235878a + ae83d8e commit 24c37f5

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

internal/fs/fs.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -374,16 +374,16 @@ func IsNonEmptyDir(name string) (bool, error) {
374374

375375
// IsRegular determines if the path given is a regular file or not.
376376
func IsRegular(name string) (bool, error) {
377-
// TODO: lstat?
378377
fi, err := os.Stat(name)
379378
if os.IsNotExist(err) {
380379
return false, nil
381380
}
382381
if err != nil {
383382
return false, err
384383
}
385-
if fi.IsDir() {
386-
return false, errors.Errorf("%q is a directory, should be a file", name)
384+
mode := fi.Mode()
385+
if mode&os.ModeType != 0 {
386+
return false, errors.Errorf("%q is a %v, expected a file", name, mode)
387387
}
388388
return true, nil
389389
}

0 commit comments

Comments
 (0)