pathDepth returns the depth of a given path by counting its components. It uses filepath.Separator, which ensures correct behavior across all platforms (Windows, macOS, Linux), regardless of the underlying path separator.
(path string)
| 72 | // It uses filepath.Separator, which ensures correct behavior across all platforms |
| 73 | // (Windows, macOS, Linux), regardless of the underlying path separator. |
| 74 | func pathDepth(path string) int { |
| 75 | return len(strings.Split(filepath.Clean(path), string(filepath.Separator))) |
| 76 | } |
| 77 | |
| 78 | // IsDir function returns whether a file is a directory or not |
| 79 | func IsDir(f string) bool { |
no outgoing calls