fix symlinks

This commit is contained in:
savis
2025-09-01 23:01:24 +02:00
parent 2467eb40be
commit 00d7a2540f

View File

@@ -3,6 +3,7 @@ sys.dont_write_bytecode = True
import os import os
import shutil import shutil
import subprocess
import channels import channels
GAMEDIR = os.getcwd() GAMEDIR = os.getcwd()
@@ -61,12 +62,21 @@ def try_symlink(target, link_name, is_dir):
try: try:
if os.path.lexists(link_name): if os.path.lexists(link_name):
os.remove(link_name) os.remove(link_name)
if not is_dir and os.name == "nt":
target += ".exe" if os.name == "nt": # Windows
link_name += ".exe" if is_dir:
os.symlink(target, link_name, target_is_directory=is_dir) # For directories, create junction
except OSError as e: import subprocess
print(f"> Failed to create symlink: {link_name} -> {target} ({e})") subprocess.run(["mklink", "/J", link_name, target], shell=True, check=True)
else:
# For files, copy instead of symlink
target += ".exe"
link_name += ".exe"
shutil.copy2(target, link_name)
else: # Unix-like systems
os.symlink(target, link_name, target_is_directory=is_dir)
except (OSError, subprocess.CalledProcessError) as e:
print(f"> Failed to create link: {link_name} -> {target} ({e})")
## Clearing Up Old Files ## Clearing Up Old Files
channels_dir = os.path.join(GAMEDIR, "channels") channels_dir = os.path.join(GAMEDIR, "channels")