ntdll/kernel32: #18

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



this patch implements Rtl(Set|Get)CurrentDirectory API (which were merely our internal implementation), and make use of them

A+
--
Eric Pouech
Common subdirectories: dlls/ntdll17/CVS and dlls/ntdll/CVS
diff -u -x '*~' -x '.#*' dlls/ntdll17/ntdll.spec dlls/ntdll/ntdll.spec
--- dlls/ntdll17/ntdll.spec	2003-04-05 10:09:14.000000000 +0200
+++ dlls/ntdll/ntdll.spec	2003-04-06 09:15:44.000000000 +0200
@@ -406,7 +406,7 @@
 @ stub RtlGetCallersAddress
 @ stub RtlGetCompressionWorkSpaceSize
 @ stdcall RtlGetControlSecurityDescriptor(ptr ptr ptr)
-@ stub RtlGetCurrentDirectory_U
+@ stdcall RtlGetCurrentDirectory_U(long ptr)
 @ stdcall RtlGetDaclSecurityDescriptor(ptr ptr ptr ptr)
 @ stub RtlGetElementGenericTable
 @ stdcall RtlGetFullPathName_U(wstr long ptr ptr)
@@ -508,7 +508,7 @@
 @ stub RtlSelfRelativeToAbsoluteSD
 @ stdcall RtlSetAllBits(ptr)
 @ stdcall RtlSetBits(ptr long long)
-@ stub RtlSetCurrentDirectory_U
+@ stdcall RtlSetCurrentDirectory_U(ptr)
 @ stub RtlSetCurrentEnvironment
 @ stdcall RtlSetDaclSecurityDescriptor(ptr long ptr long)
 @ stdcall RtlSetEnvironmentVariable(long long long)
Common subdirectories: dlls/ntdll17/tests and dlls/ntdll/tests
Common subdirectories: files17/CVS and files/CVS
diff -u -x '*~' -x '.#*' files17/drive.c files/drive.c
--- files17/drive.c	2003-04-05 19:35:23.000000000 +0200
+++ files/drive.c	2003-04-06 09:16:46.000000000 +0200
@@ -382,18 +382,16 @@
 /***********************************************************************
  *           DRIVE_SetCurrentDrive
  */
-int DRIVE_SetCurrentDrive( int drive )
+NTSTATUS DRIVE_SetCurrentDrive( int drive )
 {
     TDB *pTask = TASK_GetCurrent();
     if (!DRIVE_IsValid( drive ))
-    {
-        SetLastError( ERROR_INVALID_DRIVE );
-        return 0;
-    }
+        return STATUS_NO_SUCH_DEVICE;
+
     TRACE("%c:\n", 'A' + drive );
     DRIVE_CurDrive = drive;
     if (pTask) pTask->curdrive = drive | 0x80;
-    return 1;
+    return STATUS_SUCCESS;
 }
 
 
@@ -1331,13 +1329,13 @@
 }
 
 /***********************************************************************
- *       DRIVE_GetCurrentDirectory
+ *       RtlGetCurrentDirectory_U
  * Returns "X:\\path\\etc\\".
  *
  * Despite the API description, return required length including the
  * terminating null when buffer too small. This is the real behaviour.
 */
-static UINT DRIVE_GetCurrentDirectory( UINT buflen, LPWSTR buf )
+ULONG WINAPI RtlGetCurrentDirectory_U( ULONG buflen, LPWSTR buf )
 {
     UINT ret;
     LPCWSTR dos_cwd = DRIVE_GetDosCwd( DRIVE_GetCurrentDrive() );
@@ -1352,6 +1350,38 @@
     return ret;
 }
 
+/******************************************************************
+ *		RtlSetCurrentDirectory_U
+ *
+ */
+NTSTATUS WINAPI RtlSetCurrentDirectory_U(UNICODE_STRING* us)
+{
+    int drive, olddrive = DRIVE_GetCurrentDrive();
+    LPCWSTR dir = us->Buffer;
+    NTSTATUS ret;
+
+    if (dir[0] && (dir[1]==':'))
+    {
+        drive = toupperW( *dir ) - 'A';
+        dir += 2;
+    }
+    else
+	drive = olddrive;
+
+    /* WARNING: we need to set the drive before the dir, as DRIVE_Chdir
+       sets pTask->curdir only if pTask->curdrive is drive */
+    ret = DRIVE_SetCurrentDrive( drive );
+    if (ret == STATUS_SUCCESS)
+    {
+        /* FIXME: what about empty strings? Add a \\ ? */
+        if (!DRIVE_Chdir( drive, dir )) 
+        {
+            DRIVE_SetCurrentDrive(olddrive);
+            return FALSE;
+        }
+    }
+    return ret;
+}
 
 /***********************************************************************
  *           DRIVE_BuildEnv
@@ -1720,7 +1750,7 @@
 {
     WCHAR cur_dirW[MAX_PATH];
 
-    DRIVE_GetCurrentDirectory(MAX_PATH, cur_dirW);
+    RtlGetCurrentDirectory_U(MAX_PATH, cur_dirW);
     return (UINT16)WideCharToMultiByte(CP_ACP, 0, cur_dirW, -1, buf, buflen, NULL, NULL);
 }
 
@@ -1734,7 +1764,7 @@
     WCHAR longname[MAX_PATHNAME_LEN];
     WCHAR shortname[MAX_PATHNAME_LEN];
 
-    ret = DRIVE_GetCurrentDirectory(MAX_PATHNAME_LEN, shortname);
+    ret = RtlGetCurrentDirectory_U(MAX_PATHNAME_LEN, shortname);
     if ( ret > MAX_PATHNAME_LEN ) {
       ERR_(file)("pathnamelength (%d) > MAX_PATHNAME_LEN!\n", ret );
       return ret;
@@ -1790,30 +1820,20 @@
  */
 BOOL WINAPI SetCurrentDirectoryW( LPCWSTR dir )
 {
-    int drive, olddrive = DRIVE_GetCurrentDrive();
+    UNICODE_STRING      us;
+    NTSTATUS            nts;
 
     if (!dir)
     {
         SetLastError(ERROR_INVALID_PARAMETER);
 	return FALSE;
     }
-    if (dir[0] && (dir[1]==':'))
+    RtlInitUnicodeString(&us, dir);
+    nts = RtlSetCurrentDirectory_U(&us);
+    if (nts != STATUS_SUCCESS)
     {
-        drive = toupperW( *dir ) - 'A';
-        dir += 2;
-    }
-    else
-	drive = olddrive;
-
-    /* WARNING: we need to set the drive before the dir, as DRIVE_Chdir
-       sets pTask->curdir only if pTask->curdrive is drive */
-    if (!(DRIVE_SetCurrentDrive( drive )))
-	return FALSE;
-
-    /* FIXME: what about empty strings? Add a \\ ? */
-    if (!DRIVE_Chdir( drive, dir )) {
-	DRIVE_SetCurrentDrive(olddrive);
-	return FALSE;
+        SetLastError( RtlNtStatusToDosError( nts ) );
+        return FALSE;
     }
     return TRUE;
 }
@@ -1835,7 +1855,13 @@
 
     if (RtlCreateUnicodeStringFromAsciiz(&dirW, dir))
     {
-        ret = SetCurrentDirectoryW(dirW.Buffer);
+        NTSTATUS nts;
+
+        nts = RtlSetCurrentDirectory_U(&dirW);
+        if (nts != STATUS_SUCCESS)
+            SetLastError( RtlNtStatusToDosError( nts ) );
+        else
+            ret = TRUE;
         RtlFreeUnicodeString(&dirW);
     }
     else
Common subdirectories: if163217/CVS and if1632/CVS
Common subdirectories: include17/bitmaps and include/bitmaps
Common subdirectories: include17/CVS and include/CVS
diff -u -x '*~' -x '.#*' include17/drive.h include/drive.h
--- include17/drive.h	2002-08-27 18:05:41.000000000 +0200
+++ include/drive.h	2003-04-05 19:33:27.000000000 +0200
@@ -22,6 +22,7 @@
 #define __WINE_DRIVE_H
 
 #include "windef.h"
+#include "winternl.h"
 
 #define MAX_DOS_DRIVES  26
 
@@ -37,7 +38,7 @@
 extern int DRIVE_Init(void);
 extern int DRIVE_IsValid( int drive );
 extern int DRIVE_GetCurrentDrive(void);
-extern int DRIVE_SetCurrentDrive( int drive );
+extern NTSTATUS DRIVE_SetCurrentDrive( int drive );
 extern int DRIVE_FindDriveRoot( const char **path );
 extern int DRIVE_FindDriveRootW( LPCWSTR *path );
 extern const char * DRIVE_GetRoot( int drive );
Common subdirectories: include17/msvcrt and include/msvcrt
Common subdirectories: include17/wine and include/wine
diff -u -x '*~' -x '.#*' include17/winternl.h include/winternl.h
--- include17/winternl.h	2003-04-05 10:09:28.000000000 +0200
+++ include/winternl.h	2003-04-06 09:19:59.000000000 +0200
@@ -1259,7 +1259,9 @@
 ULONG WINAPI RtlDosSearchPath_U(LPCWSTR, LPCWSTR, LPCWSTR, ULONG, LPWSTR, LPWSTR*);
 
 ULONG WINAPI RtlGetFullPathName_U(LPCWSTR, ULONG, LPWSTR, LPWSTR*);
+ULONG WINAPI RtlGetCurrentDirectory_U(ULONG, LPWSTR);
 BOOLEAN WINAPI RtlDoesFileExists_U(LPCWSTR);
+NTSTATUS WINAPI RtlSetCurrentDirectory_U(UNICODE_STRING*);
 
 #ifdef __cplusplus
 } /* extern "C" */
Common subdirectories: loader17/CVS and loader/CVS
Common subdirectories: loader17/ne and loader/ne
Common subdirectories: relay3217/CVS and relay32/CVS
Common subdirectories: scheduler17/CVS and scheduler/CVS

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux