- Ensure we correctly add a backslash like Windows 98/XP do.

- Generate filenames that look like Windows does (no left digit
  padding).
This commit is contained in:
Mike Hearn 2004-01-16 04:49:13 +00:00 committed by Alexandre Julliard
parent c4dd56bc25
commit 517248d7bc
2 changed files with 21 additions and 4 deletions

View File

@ -618,6 +618,23 @@ static void test_CreateFileW(void)
ok(ret, "DeleteFileW: error %ld\n", GetLastError()); 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("C:", "abc", 1, out);
ok( result != 0, "GetTempFileNameA: error %ld\n", GetLastError() );
ok( ((out[0] == 'C') && (out[1] == ':')) && (out[2] == '\\'), "GetTempFileNameA: first three characters should be C:\\, 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 ) static void test_DeleteFileA( void )
{ {
BOOL ret; BOOL ret;
@ -972,6 +989,7 @@ START_TEST(file)
test__llopen( ); test__llopen( );
test__lread( ); test__lread( );
test__lwrite( ); test__lwrite( );
test_GetTempFileNameA();
test_CopyFileA(); test_CopyFileA();
test_CopyFileW(); test_CopyFileW();
test_CreateFileA(); test_CreateFileA();

View File

@ -905,7 +905,7 @@ UINT WINAPI GetTempFileNameA( LPCSTR path, LPCSTR prefix, UINT unique,
UINT WINAPI GetTempFileNameW( LPCWSTR path, LPCWSTR prefix, UINT unique, UINT WINAPI GetTempFileNameW( LPCWSTR path, LPCWSTR prefix, UINT unique,
LPWSTR buffer ) 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; DOS_FULL_NAME full_name;
int i; int i;
@ -920,9 +920,8 @@ UINT WINAPI GetTempFileNameW( LPCWSTR path, LPCWSTR prefix, UINT unique,
strcpyW( buffer, path ); strcpyW( buffer, path );
p = buffer + strlenW(buffer); p = buffer + strlenW(buffer);
/* add a \, if there isn't one and path is more than just the drive letter ... */ /* add a \, if there isn't one */
if ( !((strlenW(buffer) == 2) && (buffer[1] == ':')) if ((p == buffer) || (p[-1] != '\\')) *p++ = '\\';
&& ((p == buffer) || (p[-1] != '\\'))) *p++ = '\\';
for (i = 3; (i > 0) && (*prefix); i--) *p++ = *prefix++; for (i = 3; (i > 0) && (*prefix); i--) *p++ = *prefix++;