Fix for path handling with "/" mapped as a drive

Warren_Baird at cimmetry.com Warren_Baird at cimmetry.com
Thu Feb 6 09:25:43 CST 2003



ChangeLog:

     Fixed a special case in DOSFS_GetFullName() for files mapped through
     the drive "/".

Description:

     There was already code trying to support a "/" drive, but it
     wasn't quite working.  We had to add a special case if root is
     "/".


Warren Baird : Warren_Baird at cimmetry.com
Louis Thibault
Dave Belanger

diff -ur clean/wine/files/dos_fs.c wine/files/dos_fs.c
--- clean/wine/files/dos_fs.c Wed Jan 29 15:31:01 2003
+++ wine/files/dos_fs.c  Mon Feb  3 13:55:25 2003
@@ -973,7 +973,7 @@
         drive = toupperW(*p) - 'A';
         *name += 2;
     }
-    else if (*p == '/') /* Absolute Unix path? */
+    else if ((*p == '/') || (*p == '\\')) /* Absolute Unix path? */
     {
         if ((drive = DRIVE_FindDriveRootW( name )) == -1)
         {
@@ -1032,7 +1032,8 @@
     strcpyW( full->short_name, driveA_rootW );
     full->short_name[0] += full->drive;

-    if ((*name == '\\') || (*name == '/'))  /* Absolute path */
+    if ((*name == '\\') || (*name == '/') ||      /* Absolute path */
+       ((root[0] == '/') && (root[1] == '\0')))   /* root directory */
     {
         while ((*name == '\\') || (*name == '/')) name++;
     }
@@ -1485,21 +1486,22 @@
         FIXME("internal: error getting DOS Drive Root\n");
         return 0;
       }
-    if (!strcmp(root,"/"))
-      {(!strcmp(root,"/"))rror
-        /* we have just the last / and we need it. */
-        p_l = full_name.long_name;
-      }
-    else
-      {
-        p_l = full_name.long_name + strlen(root);
-      }
+
+    p_l = full_name.long_name +strlen(root);
     /* append long name (= unix name) to drive */
     MultiByteToWideChar(DRIVE_GetCodepage(drive), 0, p_l, -1,
                             full_name.short_name + 2, MAX_PATHNAME_LEN - 3);
     /* append name to treat */
     namelen= strlenW(full_name.short_name);
-    p = (LPWSTR)name;
+
+    if (!strcmp(root,"/"))
+    {
+        p = (LPWSTR)name + 1;
+    }
+    else
+    {
+         p = (LPWSTR)name;
+    }
     if (driveletter)
       p += 2; /* skip drive name when appending */
     if (namelen + 2 + strlenW(p) > MAX_PATHNAME_LEN)

diff -ur clean/wine/files/drive.c wine/files/drive.c
--- clean/wine/files/drive.c  Wed Jan 29 15:31:01 2003
+++ wine/files/drive.c   Mon Feb  3 13:51:10 2003
@@ -479,6 +479,7 @@
 {
     int drive, rootdrive = -1;
     char buffer[MAX_PATHNAME_LEN];
+    char* pBuffer;
     LPCWSTR p = *path;
     int len, match_len = -1;

@@ -490,6 +491,9 @@
         WideCharToMultiByte(DOSDrives[drive].codepage, 0, *path, -1,
                             buffer, MAX_PATHNAME_LEN, NULL, NULL);

+         while ((pBuffer = strchr( buffer, '\\' )) != NULL)
+           *pBuffer = '/';
+
         len = strlen(DOSDrives[drive].root);
         if(strncmp(DOSDrives[drive].root, buffer, len))
             continue;
@@ -1093,19 +1097,11 @@
 int DRIVE_Chdir( int drive, LPCWSTR path )
 {
     DOS_FULL_NAME full_name;
-    WCHAR buffer[MAX_PATHNAME_LEN];
     LPSTR unix_cwd;
     BY_HANDLE_FILE_INFORMATION info;
     TDB *pTask = TASK_GetCurrent();

-    buffer[0] = 'A' + drive;
-    buffer[1] = ':';
-    buffer[2] = 0;
-    TRACE("(%s,%s)\n", debugstr_w(buffer), debugstr_w(path) );
-    strncpyW( buffer + 2, path, MAX_PATHNAME_LEN - 2 );
-    buffer[MAX_PATHNAME_LEN - 1] = 0; /* ensure 0 termination */
-
-    if (!DOSFS_GetFullName( buffer, TRUE, &full_name )) return 0;
+    if (!DOSFS_GetFullName( path, TRUE, &full_name )) return 0;
     if (!FILE_Stat( full_name.long_name, &info, NULL )) return 0;
     if (!(info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
     {
@@ -1786,6 +1782,7 @@
  */
 BOOL WINAPI SetCurrentDirectoryW( LPCWSTR dir )
 {
+    DOS_FULL_NAME full_name;
     int drive, olddrive = DRIVE_GetCurrentDrive();

     if (!dir)
@@ -1797,6 +1794,10 @@
     {
         drive = toupperW( *dir ) - 'A';
         dir += 2;
+    }
+    else if ( DOSFS_GetFullName( dir, FALSE, &full_name ) )
+    {
+        drive = full_name.drive;
     }
     else
     drive = olddrive;





More information about the wine-patches mailing list