winedos: per drive current directory

Markus Amsler markus.amsler at oribi.org
Thu Oct 21 09:07:01 CDT 2004


Microsoft's Segmented-Executable Linker Version 5.10 shipped with QBasic 
7.1 needs per drive current directory.

Changelog
* Implement per drive current directory.
-------------- next part --------------
Index: dlls/winedos/int21.c
===================================================================
RCS file: /home/wine/wine/dlls/winedos/int21.c,v
retrieving revision 1.72
diff -u -r1.72 int21.c
--- dlls/winedos/int21.c	22 Sep 2004 02:46:39 -0000	1.72
+++ dlls/winedos/int21.c	21 Oct 2004 13:59:51 -0000
@@ -47,17 +47,6 @@
 #include "wine/exception.h"
 
 /*
- * Note:
- * - Most of the file related functions are wrong. NT's kernel32
- *   doesn't maintain a per drive current directory, while DOS does. 
- *   We should in fact keep track in here of those per driver
- *   directories, and use this infro while dealing with partial paths
- *   (drive defined, but only relative paths). This could even be
- *   created as an array of CDS (there should be an entry for that in
- *   the LOL)
- */
-
-/*
  * Forward declarations.
  */
 static BOOL INT21_RenameFile( CONTEXT86 *context );
@@ -282,6 +271,9 @@
 
 #define NB_MAGIC_DEVICES  (sizeof(magic_devices)/sizeof(magic_devices[0]))
 
+/* per drive directory cache */
+static WCHAR perdrive_directory[MAX_DOS_DRIVES][MAX_PATH];
+
 
 /* Many calls translate a drive argument like this:
    drive number (00h = default, 01h = A:, etc)
@@ -350,17 +342,44 @@
 
 
 /***********************************************************************
+ *           INT21_InitCurrentDrives
+ *
+ * Fills the current directory cache with default values.
+ */
+static void INT21_InitCurrentDrives()
+{
+    BYTE curr_drive = INT21_GetCurrentDrive();
+    int i;
+    for (i=0; i<MAX_DOS_DRIVES; i++){
+        if (i != curr_drive){
+            perdrive_directory[i][0] = 'A' + i;
+            perdrive_directory[i][1] = ':';
+            perdrive_directory[i][2] = 0;
+        }
+    }
+}
+
+
+/***********************************************************************
  *           INT21_SetCurrentDrive
  *
  * Set current drive. Uses scheme (0=A:, 1=B:, 2=C:, ...).
  */
 static void INT21_SetCurrentDrive( BYTE drive )
 {
-    WCHAR drivespec[3] = {'A', ':', 0};
-
-    drivespec[0] += drive;
+    BYTE curr_drive = INT21_GetCurrentDrive();
+        
+    if (!perdrive_directory[0][0])
+        INT21_InitCurrentDrives();
+        
+    /* save the current directory */
+    if (!GetCurrentDirectoryW( MAX_PATH, perdrive_directory[curr_drive] ))
+    {
+        TRACE( "Failed to get current drive.\n" );
+    }
 
-    if (!SetCurrentDirectoryW( drivespec ))
+    /* resotre the current directory */
+    if (!SetCurrentDirectoryW( perdrive_directory[drive] ))
         TRACE( "Failed to set current drive.\n" );
 }
 


More information about the wine-patches mailing list