diff --git a/devlib/utils/misc.py b/devlib/utils/misc.py index 9565f47..857e99d 100644 --- a/devlib/utils/misc.py +++ b/devlib/utils/misc.py @@ -445,6 +445,19 @@ def as_relative(path): return path.lstrip(os.sep) +def commonprefix(file_list, sep=os.sep): + """ + Find the lowest common base folder of a passed list of files. + """ + common_path = os.path.commonprefix(file_list) + cp_split = common_path.split(sep) + other_split = file_list[0].split(sep) + last = len(cp_split) - 1 + if cp_split[last] != other_split[last]: + cp_split = cp_split[:-1] + return sep.join(cp_split) + + def get_cpu_mask(cores): """Return a string with the hex for the cpu mask for the specified core numbers.""" mask = 0