diff options
Diffstat (limited to 'meta/lib/oe/path.py')
-rw-r--r-- | meta/lib/oe/path.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/meta/lib/oe/path.py b/meta/lib/oe/path.py index 1ea03d5d56..76c58fa760 100644 --- a/meta/lib/oe/path.py +++ b/meta/lib/oe/path.py | |||
@@ -237,3 +237,25 @@ def realpath(file, root, use_physdir = True, loop_cnt = 100, assume_dir = False) | |||
237 | raise | 237 | raise |
238 | 238 | ||
239 | return file | 239 | return file |
240 | |||
241 | def is_path_parent(possible_parent, *paths): | ||
242 | """ | ||
243 | Return True if a path is the parent of another, False otherwise. | ||
244 | Multiple paths to test can be specified in which case all | ||
245 | specified test paths must be under the parent in order to | ||
246 | return True. | ||
247 | """ | ||
248 | def abs_path_trailing(pth): | ||
249 | pth_abs = os.path.abspath(pth) | ||
250 | if not pth_abs.endswith(os.sep): | ||
251 | pth_abs += os.sep | ||
252 | return pth_abs | ||
253 | |||
254 | possible_parent_abs = abs_path_trailing(possible_parent) | ||
255 | if not paths: | ||
256 | return False | ||
257 | for path in paths: | ||
258 | path_abs = abs_path_trailing(path) | ||
259 | if not path_abs.startswith(possible_parent_abs): | ||
260 | return False | ||
261 | return True | ||