Account for possible missing backslah in GetTempPath

Uwe Bonnes bon at elektron.ikp.physik.tu-darmstadt.de
Thu May 9 11:33:53 CDT 2002


Changelog:
	files/directory.c: GetTempPath[A|W]
	Acount for a possible missing backslash for size calculation	
-- 
Uwe Bonnes                bon at elektron.ikp.physik.tu-darmstadt.de

Free Software: If you contribute nothing, expect nothing
--
Index: wine/files/directory.c
===================================================================
RCS file: /home/wine/wine/files/directory.c,v
retrieving revision 1.45
diff -u -r1.45 directory.c
--- wine/files/directory.c	9 Mar 2002 23:50:37 -0000	1.45
+++ wine/files/directory.c	9 May 2002 16:31:31 -0000
@@ -186,6 +186,21 @@
         if (!(ret = GetEnvironmentVariableA( "TEMP", path, count )))
             if (!(ret = GetCurrentDirectoryA( count, path )))
                 return 0;
+    if ((ret) && (ret +1 > count))
+      /* We need to return the required length including the 
+	 trailing backslash. So we have to acually get the string
+	 to test if the backslash is there */
+      {
+	char *buffer;
+	UINT ret1;
+	if ((buffer = HeapAlloc( GetProcessHeap(), 0, ret )))
+	  {
+	    ret1 = GetTempPathA(ret,buffer);
+	    if (buffer[ret1-1] != '\\')
+	      ret++;
+	    HeapFree( GetProcessHeap(), 0, buffer );
+	  }
+      }
     if (count && (ret < count - 1) && (path[ret-1] != '\\'))
     {
         path[ret++] = '\\';
@@ -207,6 +222,21 @@
         if (!(ret = GetEnvironmentVariableW( temp, path, count )))
             if (!(ret = GetCurrentDirectoryW( count, path )))
                 return 0;
+    if ((ret) && (ret +1 > count))
+      /* We need to return the required length including the 
+	 trailing backslash. So we have to acually get the string
+	 to test if the backslash is there */
+      {
+	WCHAR *buffer;
+	UINT ret1;
+	if ((buffer = HeapAlloc( GetProcessHeap(), 0, ret )))
+	  {
+	    ret1 = GetTempPathW(ret,buffer);
+	    if (buffer[ret1-1] != '\\')
+	      ret++;
+	    HeapFree( GetProcessHeap(), 0, buffer );
+	  }
+      }
     if (count && (ret < count - 1) && (path[ret-1] != '\\'))
     {
         path[ret++] = '\\';



More information about the wine-devel mailing list