build: prevent data loss when a CMakeCache.txt is in the root directory

This commit is contained in:
Gabriel Ferreira
2023-08-26 23:42:03 -03:00
parent 6c2f0bc739
commit 781e37e40c

3
ns3
View File

@@ -430,7 +430,8 @@ def print_and_buffer(message):
def remove_dir(dir_to_remove, dry_run, directory_qualifier=""): def remove_dir(dir_to_remove, dry_run, directory_qualifier=""):
dir_to_remove = os.path.abspath(dir_to_remove) dir_to_remove = os.path.abspath(dir_to_remove)
if os.path.exists(dir_to_remove): if os.path.exists(dir_to_remove):
if ".." in os.path.relpath(dir_to_remove, ns3_path): if (".." in os.path.relpath(dir_to_remove, ns3_path)
or os.path.abspath(dir_to_remove) == os.path.abspath(ns3_path)):
# In case the directory to remove isn't within # In case the directory to remove isn't within
# the current ns-3 directory, print an error # the current ns-3 directory, print an error
# message for the dry-run case # message for the dry-run case