Skip to content

Commit 4b2ba2b

Browse files
shymegaConnor Field
andcommitted
feat: Add check for validating symlinks in pfx/dosdevices
Inspired by #251, and derives some code from that, therefore: Co-authored-by: Connor Field <connor@connorfield.com>
1 parent f444a33 commit 4b2ba2b

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

src/wemod.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,25 @@ def init(proton: str, iswine: bool = False) -> None:
560560
[None],
561561
[None],
562562
)
563+
# Ensure dosdevices exists and `drive_c`/`drive_z` are correctly symlinked.
564+
dosdevices = os.path.join(WINEPREFIX, "dosdevices")
565+
566+
# Validate symlinks.
567+
if not os.path.isdir(dosdevices):
568+
os.makedirs(dosdevices)
569+
from mainutils import create_symlink
570+
c_drive = os.path.join(dosdevices, "c:")
571+
z_drive = os.path.join(dosdevices, "z:")
572+
# Check c_drive is a symlink.
573+
if not os.path.islink(c_drive) or os.readlink(c_drive) != '../drive_c':
574+
create_symlink("../drive_c", c_drive)
575+
# Check z_drive is a symlink.
576+
if not os.path.islink(z_drive) or os.readlink(z_drive) != '/':
577+
create_symlink("/", z_drive)
578+
579+
assert os.path.islink(c_drive) and os.readlink(c_drive) == '../drive_c', f"{dosdevices} does not have a valid `c_drive` symlink. Please delete the prefix and try again."
580+
assert os.path.islink(z_drive) and os.readlink(z_drive) == '/', f"{dosdevices} does not have a valid `z_drive` symlink. Please delete the prefix and try again."
581+
563582
syncwemod() # Sync WeMod data
564583
log(
565584
f"Copied Proton version {cut_version[0]}.{cut_version[1]} prefix to game prefix that was on version {current_version_parts[0]}.{current_version_parts[1]}"

0 commit comments

Comments
 (0)