From f19e153ca21c2b2ceaa521375da3fde03bc2d21c Mon Sep 17 00:00:00 2001 From: Timi007 Date: Sun, 31 Dec 2023 16:47:25 +0100 Subject: [PATCH] Do not require P-drive on setup links and delete links before creation (#95) * Do not require P-drive on setup links * Delete links before creating them again --- tools/setup_filepatching_links.py | 35 ++++++++++++++++++------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/tools/setup_filepatching_links.py b/tools/setup_filepatching_links.py index 83f3d36..9738d1d 100644 --- a/tools/setup_filepatching_links.py +++ b/tools/setup_filepatching_links.py @@ -24,8 +24,8 @@ def main(): This script will create your Metis dev environment for you. Before you run this, you should already have: - - The Arma 3 Tools installed properly via Steam - - A properly set up P-drive + - The Arma 3 Tools installed properly via Steam (optional) + - A properly set up P-drive (optional) If you have not done those things yet, please abort this script in the next step and do so first. @@ -42,10 +42,6 @@ def main(): print("Failed to determine Arma 3 Path.") return 2 - if not os.path.exists("P:\\"): - print("No P-drive detected.") - return 3 - scriptpath = os.path.realpath(__file__) projectpath = os.path.dirname(os.path.dirname(scriptpath)) devpath = os.path.join(projectpath, '.hemttout', 'dev') @@ -63,17 +59,26 @@ def main(): try: os.makedirs(devpath, exist_ok=True) - if not os.path.exists(os.path.join("P:", MAINDIR, PROJECTDIR)): - os.makedirs(os.path.join("P:", MAINDIR), exist_ok=True) - _winapi.CreateJunction(devpath, os.path.join("P:", MAINDIR, PROJECTDIR)) - else: - print("Link on P: already exists. Skipping it.") + if os.path.exists("P:\\"): + link = os.path.join("P:", MAINDIR, PROJECTDIR) + if os.path.exists(link): + os.unlink(link) + print("Previous link on P: deleted.") - if not os.path.exists(os.path.join(armapath, MAINDIR, PROJECTDIR)): - os.makedirs(os.path.join(armapath, MAINDIR), exist_ok=True) - _winapi.CreateJunction(devpath, os.path.join(armapath, MAINDIR, PROJECTDIR)) + os.makedirs(os.path.dirname(link), exist_ok=True) + _winapi.CreateJunction(devpath, link) + print("Link on P: created.") else: - print("Link in Arma directory already exists. Skipping it.") + print("No P-drive detected. Skipping it.") + + link = os.path.join(armapath, MAINDIR, PROJECTDIR) + if os.path.exists(link): + os.unlink(link) + print("Previous link in Arma directory deleted.") + + os.makedirs(os.path.dirname(link), exist_ok=True) + _winapi.CreateJunction(devpath, link) + print("Link in Arma directory created.") except: print("Something went wrong during the link creation. Please finish the setup manually.") raise