(directory string, callback func(directory string) (result T, stop bool))
| 1064 | } |
| 1065 | |
| 1066 | func ForEachAncestorDirectory[T any](directory string, callback func(directory string) (result T, stop bool)) (result T, ok bool) { |
| 1067 | for { |
| 1068 | result, stop := callback(directory) |
| 1069 | if stop { |
| 1070 | return result, true |
| 1071 | } |
| 1072 | |
| 1073 | parentPath := GetDirectoryPath(directory) |
| 1074 | if parentPath == directory { |
| 1075 | var zero T |
| 1076 | return zero, false |
| 1077 | } |
| 1078 | |
| 1079 | directory = parentPath |
| 1080 | } |
| 1081 | } |
| 1082 | |
| 1083 | func ForEachAncestorDirectoryPath[T any](directory Path, callback func(directory Path) (result T, stop bool)) (result T, ok bool) { |
| 1084 | return ForEachAncestorDirectory(string(directory), func(directory string) (T, bool) { |
no test coverage detected