From 161a53f254887b5a0b52cb37b8f15e20daafa5ab Mon Sep 17 00:00:00 2001 From: Vitaliy Margolen Date: Thu, 16 Nov 2006 12:28:49 -0700 Subject: [PATCH] winecfg: Allow editing of broken drive links. --- programs/winecfg/drive.c | 41 +++++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/programs/winecfg/drive.c b/programs/winecfg/drive.c index 36d7a1d729..9e81ab24e2 100644 --- a/programs/winecfg/drive.c +++ b/programs/winecfg/drive.c @@ -21,6 +21,9 @@ * */ +#include "config.h" +#include "wine/port.h" + #include #include #include @@ -35,6 +38,7 @@ #include #include #include +#include #include "winecfg.h" #include "resource.h" @@ -263,12 +267,11 @@ void load_drives() int drivecount = 0, i; int retval; static const int arraysize = 512; + const char *config_dir = wine_get_config_dir(); + char *path; WINE_TRACE("\n"); - /* FIXME: broken symlinks in $WINEPREFIX/dosdevices will not be - returned by this API, so we need to handle that */ - /* setup the drives array */ dev = devices = HeapAlloc(GetProcessHeap(), 0, arraysize); len = GetLogicalDriveStrings(arraysize, devices); @@ -360,8 +363,37 @@ void load_drives() drivecount++; } + /* Find all the broken symlinks we might have and add them as well. */ + + len = strlen(config_dir) + sizeof("/dosdevices/a:"); + if (!(path = HeapAlloc(GetProcessHeap(), 0, len))) + return; + + strcpy(path, config_dir); + strcat(path, "/dosdevices/a:"); + + for (i = 0; i < 26; i++) + { + char buff[MAX_PATH]; + struct stat st; + int cnt; + + if (drives[i].in_use) continue; + path[len - 3] = 'a' + i; + + if (lstat(path, &st) == -1 || !S_ISLNK(st.st_mode)) continue; + if ((cnt = readlink(path, buff, sizeof(buff))) == -1) continue; + buff[cnt] = '\0'; + + WINE_TRACE("found broken symlink %s -> %s\n", path, buff); + add_drive('A' + i, buff, "", "0", DRIVE_UNKNOWN); + + drivecount++; + } + WINE_TRACE("found %d drives\n", drivecount); + HeapFree(GetProcessHeap(), 0, path); HeapFree(GetProcessHeap(), 0, dev); } @@ -421,9 +453,8 @@ void apply_drive_changes(void) if(!retval) { WINE_TRACE(" GetVolumeInformation() for '%s' failed\n", devicename); - WINE_TRACE(" Skipping this drive\n"); PRINTERROR(); - continue; /* skip this drive */ + volumeNameBuffer[0] = '\0'; } WINE_TRACE(" current path: '%s', new path: '%s'\n",