prefix can be NULL for GetTempFileNameW.

This commit is contained in:
Phil Lodwick 2005-11-12 19:09:06 +00:00 committed by Alexandre Julliard
parent 58d6722e7a
commit bf8319fdd5
2 changed files with 13 additions and 3 deletions

View File

@ -651,7 +651,7 @@ UINT WINAPI GetTempFileNameW( LPCWSTR path, LPCWSTR prefix, UINT unique, LPWSTR
int i; int i;
LPWSTR p; LPWSTR p;
if ( !path || !prefix || !buffer ) if ( !path || !buffer )
{ {
SetLastError( ERROR_INVALID_PARAMETER ); SetLastError( ERROR_INVALID_PARAMETER );
return 0; return 0;
@ -663,7 +663,8 @@ UINT WINAPI GetTempFileNameW( LPCWSTR path, LPCWSTR prefix, UINT unique, LPWSTR
/* add a \, if there isn't one */ /* add a \, if there isn't one */
if ((p == buffer) || (p[-1] != '\\')) *p++ = '\\'; if ((p == buffer) || (p[-1] != '\\')) *p++ = '\\';
for (i = 3; (i > 0) && (*prefix); i--) *p++ = *prefix++; if (prefix)
for (i = 3; (i > 0) && (*prefix); i--) *p++ = *prefix++;
unique &= 0xffff; unique &= 0xffff;

View File

@ -335,9 +335,18 @@ static void test_InitPathA(CHAR *newdir, CHAR *curDrive, CHAR *otherDrive)
sprintf(tmpstr1,"pat%x.tmp",id & 0xffff); sprintf(tmpstr1,"pat%x.tmp",id & 0xffff);
ok(lstrcmpiA(newdir+lstrlenA(tmppath),tmpstr)==0 || ok(lstrcmpiA(newdir+lstrlenA(tmppath),tmpstr)==0 ||
lstrcmpiA(newdir+lstrlenA(tmppath),tmpstr1)==0, lstrcmpiA(newdir+lstrlenA(tmppath),tmpstr1)==0,
"GetTempPath returned '%s' which doesn't match '%s' or '%s'. id=%x\n", "GetTempFileNameA returned '%s' which doesn't match '%s' or '%s'. id=%x\n",
newdir,tmpstr,tmpstr1,id); newdir,tmpstr,tmpstr1,id);
ok((id=GetTempFileNameA(tmppath,NULL,0,newdir)),"GetTempFileNameA failed\n");
sprintf(tmpstr,"%.4x.tmp",id & 0xffff);
sprintf(tmpstr1,"%x.tmp",id & 0xffff);
ok(lstrcmpiA(newdir+lstrlenA(tmppath),tmpstr)==0 ||
lstrcmpiA(newdir+lstrlenA(tmppath),tmpstr1)==0,
"GetTempFileNameA returned '%s' which doesn't match '%s' or '%s'. id=%x\n",
newdir,tmpstr,tmpstr1,id);
/* Find first valid drive letter that is neither newdir[0] nor curDrive */ /* Find first valid drive letter that is neither newdir[0] nor curDrive */
drives = GetLogicalDrives() & ~(1<<(newdir[0]-'A')); drives = GetLogicalDrives() & ~(1<<(newdir[0]-'A'));
if( *curDrive != NOT_A_VALID_DRIVE) if( *curDrive != NOT_A_VALID_DRIVE)