From 8f1fca839c837bbb8637707b780b7d753c8e4591 Mon Sep 17 00:00:00 2001 From: brent saner Date: Fri, 17 Jul 2026 17:22:03 -0400 Subject: [PATCH] v1.16.4 ADDED: * paths: ** IsDirOrLinkDir --- paths/funcs.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/paths/funcs.go b/paths/funcs.go index 4aac364..fec7175 100644 --- a/paths/funcs.go +++ b/paths/funcs.go @@ -161,6 +161,29 @@ func GetFirstWithRef(p []string) (content []byte, isDir, ok bool, idx int) { return } +/* +IsDirOrLinkDir returns true if path p is a directory OR a symlink to a directory. + +isDir will be true if p is either a directory or a symlink directory +(symlinks are followed and recursed). + +isLink will only be true if p is a symlink to a directory (or a symlink to a symlink +to a directory, etc.). +*/ +func IsDirOrLinkDir(p string) (isDir, isLink bool, err error) { + + var stat fs.FileInfo + var pTmp string = p // avoid weird runtime-y race-y things + + if _, _, isLink, _, stat, err = RealPathExistsStatTarget(&pTmp); err != nil { + return + } + + isDir = stat.IsDir() + + return +} + /* Len returns the number of path segments in p, as split with the same param signature to [Segment].