Skip to content

Commit

Permalink
Do not require P-drive on setup links and delete links before creation (
Browse files Browse the repository at this point in the history
#17)

* Do not require P-drive on setup links

* Delete links before creating them again
  • Loading branch information
Timi007 authored Dec 31, 2023
1 parent 7d20c3a commit 2b9cda5
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions tools/setup_filepatching_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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')
Expand All @@ -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
Expand Down

0 comments on commit 2b9cda5

Please sign in to comment.