Skip to content

Commit a0b5690

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 98662ae commit a0b5690

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

src/wemod.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,26 @@ 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+
570+
from mainutils import create_symlink
571+
c_drive = os.path.join(dosdevices, "c:")
572+
z_drive = os.path.join(dosdevices, "z:")
573+
# Check c_drive is a symlink.
574+
if not os.path.islink(c_drive) or os.readlink(c_drive) != '../drive_c':
575+
create_symlink("../drive_c", c_drive)
576+
# Check z_drive is a symlink.
577+
if not os.path.islink(z_drive) or os.readlink(z_drive) != '/':
578+
create_symlink("/", z_drive)
579+
580+
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."
581+
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."
582+
563583
syncwemod() # Sync WeMod data
564584
log(
565585
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)