GetTempFileName conformance improvements

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

 



ChangeLog:
- Ensure we correctly add a backslash like Windows 98/XP do
- Generate filenames that look like Windows does (no left digit padding)

Index: files/file.c
===================================================================
RCS file: /home/wine/wine/files/file.c,v
retrieving revision 1.199
diff -u -r1.199 file.c
--- files/file.c        14 Jan 2004 04:34:20 -0000      1.199
+++ files/file.c        15 Jan 2004 14:46:58 -0000
@@ -905,7 +905,7 @@
 UINT WINAPI GetTempFileNameW( LPCWSTR path, LPCWSTR prefix, UINT unique,
                                   LPWSTR buffer )
 {
-    static const WCHAR formatW[] = {'%','0','4','x','.','t','m','p',0};
+    static const WCHAR formatW[] = {'%','x','.','t','m','p',0};
  
     DOS_FULL_NAME full_name;
     int i;
@@ -920,9 +920,8 @@
     strcpyW( buffer, path );
     p = buffer + strlenW(buffer);
  
-    /* add a \, if there isn't one and path is more than just the drive letter ... */
-    if ( !((strlenW(buffer) == 2) && (buffer[1] == ':'))
-       && ((p == buffer) || (p[-1] != '\\'))) *p++ = '\\';
+    /* add a \, if there isn't one  */
+    if ((p == buffer) || (p[-1] != '\\')) *p++ = '\\';
  
     for (i = 3; (i > 0) && (*prefix); i--) *p++ = *prefix++;
  
Index: dlls/kernel/tests/file.c
===================================================================
RCS file: /home/wine/wine/dlls/kernel/tests/file.c,v
retrieving revision 1.27
diff -u -r1.27 file.c
--- dlls/kernel/tests/file.c    9 Jan 2004 00:34:37 -0000       1.27
+++ dlls/kernel/tests/file.c    15 Jan 2004 14:47:00 -0000
@@ -618,6 +618,23 @@
     ok(ret, "DeleteFileW: error %ld\n", GetLastError());
 }
  
+
+static void test_GetTempFileNameA() {
+    UINT result;
+    char out[MAX_PATH];
+    char *expected = "c:\\windows\\abc2.tmp";
+
+    /* this test may depend on the config file settings */
+    result = GetTempFileNameA("E:", "abc", 1, out);
+    ok( result != 0, "GetTempFileNameA: error %ld\n", GetLastError() );
+    ok( ((out[0] == 'E') && (out[1] == ':')) && (out[2] == '\\'), "GetTempFileNameA: first three characters should be E:\\, string was actually %s", out );
+
+    result = GetTempFileNameA("c:\\windows\\", "abc", 2, out);
+    ok( result != 0, "GetTempFileNameA: error %ld\n", GetLastError() );
+    ok( strcasecmp( out, expected ) == 0, "GetTempFileNameA: Unexpected output \"%s\" vs \"%s\"\n", out, expected );
+}
+
+
 static void test_DeleteFileA( void )
 {
     BOOL ret;
@@ -972,6 +989,7 @@
     test__llopen(  );
     test__lread(  );
     test__lwrite(  );
+    test_GetTempFileNameA();
     test_CopyFileA();
     test_CopyFileW();
     test_CreateFileA();






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

  Powered by Linux