Vitaliy Margolen : winecfg: Allow editing of broken drive links.

Alexandre Julliard julliard at wine.codeweavers.com
Fri Nov 17 11:48:45 CST 2006


Module: wine
Branch: master
Commit: 161a53f254887b5a0b52cb37b8f15e20daafa5ab
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=161a53f254887b5a0b52cb37b8f15e20daafa5ab

Author: Vitaliy Margolen <wine-patches at kievinfo.com>
Date:   Thu Nov 16 12:28:49 2006 -0700

winecfg: Allow editing of broken drive links.

---

 programs/winecfg/drive.c |   41 ++++++++++++++++++++++++++++++++++++-----
 1 files changed, 36 insertions(+), 5 deletions(-)

diff --git a/programs/winecfg/drive.c b/programs/winecfg/drive.c
index 36d7a1d..9e81ab2 100644
--- a/programs/winecfg/drive.c
+++ b/programs/winecfg/drive.c
@@ -21,6 +21,9 @@
  *
  */
 
+#include "config.h"
+#include "wine/port.h"
+
 #include <assert.h>
 #include <stdarg.h>
 #include <stdio.h>
@@ -35,6 +38,7 @@
 #include <shlguid.h>
 #include <shlwapi.h>
 #include <shlobj.h>
+#include <wine/library.h>
 
 #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",




More information about the wine-cvs mailing list