version: Correctly return VFF_CURNEDEST in VerFindFileA.
Signed-off-by: Vijay Kiran Kamuju <infyquest@gmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
1a6458bad8
commit
91f96b2827
|
@ -1,5 +1,5 @@
|
||||||
TESTDLL = version.dll
|
TESTDLL = version.dll
|
||||||
IMPORTS = version
|
IMPORTS = version shell32
|
||||||
|
|
||||||
C_SRCS = \
|
C_SRCS = \
|
||||||
info.c \
|
info.c \
|
||||||
|
|
|
@ -24,11 +24,13 @@
|
||||||
#include "winbase.h"
|
#include "winbase.h"
|
||||||
#include "winerror.h"
|
#include "winerror.h"
|
||||||
#include "winver.h"
|
#include "winver.h"
|
||||||
|
#include "shlobj.h"
|
||||||
|
|
||||||
static void test_find_file(void)
|
static void test_find_file(void)
|
||||||
{
|
{
|
||||||
DWORD ret;
|
DWORD ret;
|
||||||
UINT dwCur, dwOut ;
|
UINT dwCur, dwOut ;
|
||||||
|
char tmp[MAX_PATH];
|
||||||
char appdir[MAX_PATH];
|
char appdir[MAX_PATH];
|
||||||
char curdir[MAX_PATH];
|
char curdir[MAX_PATH];
|
||||||
char filename[MAX_PATH];
|
char filename[MAX_PATH];
|
||||||
|
@ -115,10 +117,11 @@ static void test_find_file(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!GetModuleFileNameA(NULL, filename, MAX_PATH) ||
|
if(!GetSystemDirectoryA(windir, MAX_PATH) ||
|
||||||
!GetSystemDirectoryA(windir, MAX_PATH) ||
|
!SHGetSpecialFolderPathA(0, appdir, CSIDL_PROGRAM_FILES, FALSE) ||
|
||||||
!GetTempPathA(MAX_PATH, appdir))
|
!GetTempPathA(MAX_PATH, tmp) ||
|
||||||
trace("GetModuleFileNameA, GetSystemDirectoryA or GetTempPathA failed\n");
|
!GetTempFileNameA(tmp, "tes", 0, filename))
|
||||||
|
ok(0, "GetSystemDirectoryA, SHGetSpecialFolderPathA, GetTempPathA or GetTempFileNameA failed\n");
|
||||||
else {
|
else {
|
||||||
char *p = strrchr(filename, '\\');
|
char *p = strrchr(filename, '\\');
|
||||||
if(p) {
|
if(p) {
|
||||||
|
@ -150,7 +153,7 @@ static void test_find_file(void)
|
||||||
memset(outBuf, 0, MAX_PATH);
|
memset(outBuf, 0, MAX_PATH);
|
||||||
memset(curdir, 0, MAX_PATH);
|
memset(curdir, 0, MAX_PATH);
|
||||||
ret = VerFindFileA(VFFF_ISSHAREDFILE, filename, NULL, appdir, curdir, &dwCur, outBuf, &dwOut);
|
ret = VerFindFileA(VFFF_ISSHAREDFILE, filename, NULL, appdir, curdir, &dwCur, outBuf, &dwOut);
|
||||||
todo_wine ok(VFF_CURNEDEST == ret, "Wrong return value got %x expected VFF_CURNEDEST\n", ret);
|
ok(VFF_CURNEDEST == ret, "Wrong return value got %x expected VFF_CURNEDEST\n", ret);
|
||||||
ok(dwOut == 1 + strlen(windir), "Wrong length of buffer for current location: "
|
ok(dwOut == 1 + strlen(windir), "Wrong length of buffer for current location: "
|
||||||
"got %d(%s) expected %d\n", dwOut, outBuf, lstrlenA(windir)+1);
|
"got %d(%s) expected %d\n", dwOut, outBuf, lstrlenA(windir)+1);
|
||||||
|
|
||||||
|
@ -159,9 +162,145 @@ static void test_find_file(void)
|
||||||
memset(outBuf, 0, MAX_PATH);
|
memset(outBuf, 0, MAX_PATH);
|
||||||
memset(curdir, 0, MAX_PATH);
|
memset(curdir, 0, MAX_PATH);
|
||||||
ret = VerFindFileA(0, filename, NULL, appdir, curdir, &dwCur, outBuf, &dwOut);
|
ret = VerFindFileA(0, filename, NULL, appdir, curdir, &dwCur, outBuf, &dwOut);
|
||||||
todo_wine ok(VFF_CURNEDEST == ret, "Wrong return value got %x expected VFF_CURNEDEST\n", ret);
|
ok(VFF_CURNEDEST == ret, "Wrong return value got %x expected VFF_CURNEDEST\n", ret);
|
||||||
ok(dwOut == 1 + strlen(appdir), "Wrong length of buffer for current location: "
|
ok(dwOut == 1 + strlen(appdir), "Wrong length of buffer for current location: "
|
||||||
"got %d(%s) expected %d\n", dwOut, outBuf, lstrlenA(appdir)+1);
|
"got %d(%s) expected %d\n", dwOut, outBuf, lstrlenA(appdir)+1);
|
||||||
|
|
||||||
|
/* search for filename */
|
||||||
|
dwCur=MAX_PATH;
|
||||||
|
dwOut=MAX_PATH;
|
||||||
|
ret = VerFindFileA(0, filename, NULL, NULL, curdir, &dwCur, outBuf, &dwOut);
|
||||||
|
ok(ret & VFF_CURNEDEST, "Wrong return value got %x expected VFF_CURNEDEST set\n", ret);
|
||||||
|
|
||||||
|
dwCur=MAX_PATH;
|
||||||
|
dwOut=MAX_PATH;
|
||||||
|
ret = VerFindFileA(0, filename, NULL, empty, curdir, &dwCur, outBuf, &dwOut);
|
||||||
|
ok(ret & VFF_CURNEDEST, "Wrong return value got %x expected VFF_CURNEDEST set\n", ret);
|
||||||
|
|
||||||
|
dwCur=MAX_PATH;
|
||||||
|
dwOut=MAX_PATH;
|
||||||
|
ret = VerFindFileA(0, filename, NULL, appdir, curdir, &dwCur, outBuf, &dwOut);
|
||||||
|
ok(ret & VFF_CURNEDEST, "Wrong return value got %x expected VFF_CURNEDEST set\n", ret);
|
||||||
|
|
||||||
|
dwCur=MAX_PATH;
|
||||||
|
dwOut=MAX_PATH;
|
||||||
|
ret = VerFindFileA(VFFF_ISSHAREDFILE, filename, NULL, NULL, curdir, &dwCur, outBuf, &dwOut);
|
||||||
|
ok(ret & VFF_CURNEDEST, "Wrong return value got %x expected VFF_CURNEDEST set\n", ret);
|
||||||
|
|
||||||
|
dwCur=MAX_PATH;
|
||||||
|
dwOut=MAX_PATH;
|
||||||
|
ret = VerFindFileA(VFFF_ISSHAREDFILE, filename, NULL, empty, curdir, &dwCur, outBuf, &dwOut);
|
||||||
|
ok(ret & VFF_CURNEDEST, "Wrong return value got %x expected VFF_CURNEDEST set\n", ret);
|
||||||
|
|
||||||
|
dwCur=MAX_PATH;
|
||||||
|
dwOut=MAX_PATH;
|
||||||
|
ret = VerFindFileA(VFFF_ISSHAREDFILE, filename, NULL, appdir, curdir, &dwCur, outBuf, &dwOut);
|
||||||
|
ok(ret & VFF_CURNEDEST, "Wrong return value got %x expected VFF_CURNEDEST set\n", ret);
|
||||||
|
|
||||||
|
/* search for regedit */
|
||||||
|
dwCur=MAX_PATH;
|
||||||
|
dwOut=MAX_PATH;
|
||||||
|
ret = VerFindFileA(0, "regedit", NULL, NULL, curdir, &dwCur, outBuf, &dwOut);
|
||||||
|
ok(!ret, "Wrong return value got %x expected 0\n", ret);
|
||||||
|
|
||||||
|
dwCur=MAX_PATH;
|
||||||
|
dwOut=MAX_PATH;
|
||||||
|
ret = VerFindFileA(0, "regedit", NULL, empty, curdir, &dwCur, outBuf, &dwOut);
|
||||||
|
ok(!ret, "Wrong return value got %x expected 0\n", ret);
|
||||||
|
|
||||||
|
dwCur=MAX_PATH;
|
||||||
|
dwOut=MAX_PATH;
|
||||||
|
ret = VerFindFileA(0, "regedit", NULL, appdir, curdir, &dwCur, outBuf, &dwOut);
|
||||||
|
ok(ret & VFF_CURNEDEST, "Wrong return value got %x expected VFF_CURNEDEST set\n", ret);
|
||||||
|
|
||||||
|
dwCur=MAX_PATH;
|
||||||
|
dwOut=MAX_PATH;
|
||||||
|
ret = VerFindFileA(VFFF_ISSHAREDFILE, "regedit", NULL, NULL, curdir, &dwCur, outBuf, &dwOut);
|
||||||
|
ok(ret & VFF_CURNEDEST, "Wrong return value got %x expected VFF_CURNEDEST set\n", ret);
|
||||||
|
|
||||||
|
dwCur=MAX_PATH;
|
||||||
|
dwOut=MAX_PATH;
|
||||||
|
ret = VerFindFileA(VFFF_ISSHAREDFILE, "regedit", NULL, empty, curdir, &dwCur, outBuf, &dwOut);
|
||||||
|
ok(ret & VFF_CURNEDEST, "Wrong return value got %x expected VFF_CURNEDEST set\n", ret);
|
||||||
|
|
||||||
|
dwCur=MAX_PATH;
|
||||||
|
dwOut=MAX_PATH;
|
||||||
|
ret = VerFindFileA(VFFF_ISSHAREDFILE, "regedit", NULL, appdir, curdir, &dwCur, outBuf, &dwOut);
|
||||||
|
ok(ret & VFF_CURNEDEST, "Wrong return value got %x expected VFF_CURNEDEST set\n", ret);
|
||||||
|
|
||||||
|
/* search for regedit.exe */
|
||||||
|
dwCur=MAX_PATH;
|
||||||
|
dwOut=MAX_PATH;
|
||||||
|
ret = VerFindFileA(0, "regedit.exe", NULL, NULL, curdir, &dwCur, outBuf, &dwOut);
|
||||||
|
ok(ret & VFF_CURNEDEST, "Wrong return value got %x expected VFF_CURNEDEST set\n", ret);
|
||||||
|
|
||||||
|
dwCur=MAX_PATH;
|
||||||
|
dwOut=MAX_PATH;
|
||||||
|
ret = VerFindFileA(0, "regedit.exe", NULL, empty, curdir, &dwCur, outBuf, &dwOut);
|
||||||
|
ok(ret & VFF_CURNEDEST, "Wrong return value got %x expected VFF_CURNEDEST set\n", ret);
|
||||||
|
|
||||||
|
dwCur=MAX_PATH;
|
||||||
|
dwOut=MAX_PATH;
|
||||||
|
ret = VerFindFileA(0, "regedit.exe", NULL, appdir, curdir, &dwCur, outBuf, &dwOut);
|
||||||
|
ok(ret & VFF_CURNEDEST, "Wrong return value got %x expected VFF_CURNEDEST set\n", ret);
|
||||||
|
|
||||||
|
dwCur=MAX_PATH;
|
||||||
|
dwOut=MAX_PATH;
|
||||||
|
ret = VerFindFileA(VFFF_ISSHAREDFILE, "regedit.exe", NULL, NULL, curdir, &dwCur, outBuf, &dwOut);
|
||||||
|
ok(ret & VFF_CURNEDEST, "Wrong return value got %x expected VFF_CURNEDEST set\n", ret);
|
||||||
|
|
||||||
|
dwCur=MAX_PATH;
|
||||||
|
dwOut=MAX_PATH;
|
||||||
|
ret = VerFindFileA(VFFF_ISSHAREDFILE, "regedit.exe", NULL, empty, curdir, &dwCur, outBuf, &dwOut);
|
||||||
|
ok(ret & VFF_CURNEDEST, "Wrong return value got %x expected VFF_CURNEDEST set\n", ret);
|
||||||
|
|
||||||
|
dwCur=MAX_PATH;
|
||||||
|
dwOut=MAX_PATH;
|
||||||
|
ret = VerFindFileA(VFFF_ISSHAREDFILE, "regedit.exe", NULL, appdir, curdir, &dwCur, outBuf, &dwOut);
|
||||||
|
ok(ret & VFF_CURNEDEST, "Wrong return value got %x expected VFF_CURNEDEST set\n", ret);
|
||||||
|
|
||||||
|
/* nonexistent filename */
|
||||||
|
dwCur=MAX_PATH;
|
||||||
|
dwOut=MAX_PATH;
|
||||||
|
ret = VerFindFileA(0, "doesnotexist.exe", NULL, NULL, curdir, &dwCur, outBuf, &dwOut);
|
||||||
|
ok(!ret, "Wrong return value got %x expected 0\n", ret);
|
||||||
|
|
||||||
|
dwCur=MAX_PATH;
|
||||||
|
dwOut=MAX_PATH;
|
||||||
|
ret = VerFindFileA(0, "doesnotexist.exe", NULL, empty, curdir, &dwCur, outBuf, &dwOut);
|
||||||
|
ok(!ret, "Wrong return value got %x expected 0\n", ret);
|
||||||
|
|
||||||
|
dwCur=MAX_PATH;
|
||||||
|
dwOut=MAX_PATH;
|
||||||
|
ret = VerFindFileA(0, "doesnotexist.exe", NULL, appdir, curdir, &dwCur, outBuf, &dwOut);
|
||||||
|
ok(ret & VFF_CURNEDEST, "Wrong return value got %x expected VFF_CURNEDEST set\n", ret);
|
||||||
|
|
||||||
|
dwCur=MAX_PATH;
|
||||||
|
dwOut=MAX_PATH;
|
||||||
|
ret = VerFindFileA(0, "doesnotexist.exe", NULL, "C:\\random_path_does_not_exist", curdir, &dwCur, outBuf, &dwOut);
|
||||||
|
ok(ret & VFF_CURNEDEST, "Wrong return value got %x expected VFF_CURNEDEST set\n", ret);
|
||||||
|
|
||||||
|
dwCur=MAX_PATH;
|
||||||
|
dwOut=MAX_PATH;
|
||||||
|
ret = VerFindFileA(VFFF_ISSHAREDFILE, "doesnotexist.exe", NULL, NULL, curdir, &dwCur, outBuf, &dwOut);
|
||||||
|
ok(ret & VFF_CURNEDEST, "Wrong return value got %x expected VFF_CURNEDEST set\n", ret);
|
||||||
|
|
||||||
|
dwCur=MAX_PATH;
|
||||||
|
dwOut=MAX_PATH;
|
||||||
|
ret = VerFindFileA(VFFF_ISSHAREDFILE, "doesnotexist.exe", NULL, empty, curdir, &dwCur, outBuf, &dwOut);
|
||||||
|
ok(ret & VFF_CURNEDEST, "Wrong return value got %x expected VFF_CURNEDEST set\n", ret);
|
||||||
|
|
||||||
|
dwCur=MAX_PATH;
|
||||||
|
dwOut=MAX_PATH;
|
||||||
|
ret = VerFindFileA(VFFF_ISSHAREDFILE, "doesnotexist.exe", NULL, appdir, curdir, &dwCur, outBuf, &dwOut);
|
||||||
|
ok(ret & VFF_CURNEDEST, "Wrong return value got %x expected VFF_CURNEDEST set\n", ret);
|
||||||
|
|
||||||
|
dwCur=MAX_PATH;
|
||||||
|
dwOut=MAX_PATH;
|
||||||
|
ret = VerFindFileA(VFFF_ISSHAREDFILE, "doesnotexist.exe", NULL, "C:\\random_path_does_not_exist", curdir, &dwCur, outBuf, &dwOut);
|
||||||
|
ok(ret & VFF_CURNEDEST, "Wrong return value got %x expected VFF_CURNEDEST set\n", ret);
|
||||||
|
|
||||||
|
DeleteFileA(filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1128,16 +1128,22 @@ static int testFileExistenceA( char const * path, char const * file, BOOL excl )
|
||||||
|
|
||||||
fileinfo.cBytes = sizeof(OFSTRUCT);
|
fileinfo.cBytes = sizeof(OFSTRUCT);
|
||||||
|
|
||||||
|
if (path)
|
||||||
|
{
|
||||||
strcpy(filename, path);
|
strcpy(filename, path);
|
||||||
filenamelen = strlen(filename);
|
filenamelen = strlen(filename);
|
||||||
|
|
||||||
/* Add a trailing \ if necessary */
|
/* Add a trailing \ if necessary */
|
||||||
if(filenamelen) {
|
if(filenamelen)
|
||||||
|
{
|
||||||
if(filename[filenamelen - 1] != '\\')
|
if(filename[filenamelen - 1] != '\\')
|
||||||
strcat(filename, "\\");
|
strcat(filename, "\\");
|
||||||
}
|
}
|
||||||
else /* specify the current directory */
|
else /* specify the current directory */
|
||||||
strcpy(filename, ".\\");
|
strcpy(filename, ".\\");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
filename[0] = 0;
|
||||||
|
|
||||||
/* Create the full pathname */
|
/* Create the full pathname */
|
||||||
strcat(filename, file);
|
strcat(filename, file);
|
||||||
|
@ -1227,12 +1233,12 @@ DWORD WINAPI VerFindFileA(
|
||||||
{
|
{
|
||||||
if(testFileExistenceA(destDir, lpszFilename, FALSE)) curDir = destDir;
|
if(testFileExistenceA(destDir, lpszFilename, FALSE)) curDir = destDir;
|
||||||
else if(lpszAppDir && testFileExistenceA(lpszAppDir, lpszFilename, FALSE))
|
else if(lpszAppDir && testFileExistenceA(lpszAppDir, lpszFilename, FALSE))
|
||||||
{
|
|
||||||
curDir = lpszAppDir;
|
curDir = lpszAppDir;
|
||||||
|
|
||||||
|
if(!testFileExistenceA(systemDir, lpszFilename, FALSE))
|
||||||
retval |= VFF_CURNEDEST;
|
retval |= VFF_CURNEDEST;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else /* not a shared file */
|
else /* not a shared file */
|
||||||
{
|
{
|
||||||
destDir = lpszAppDir ? lpszAppDir : "";
|
destDir = lpszAppDir ? lpszAppDir : "";
|
||||||
|
@ -1241,15 +1247,17 @@ DWORD WINAPI VerFindFileA(
|
||||||
GetWindowsDirectoryA( winDir, MAX_PATH );
|
GetWindowsDirectoryA( winDir, MAX_PATH );
|
||||||
if(testFileExistenceA(destDir, lpszFilename, FALSE)) curDir = destDir;
|
if(testFileExistenceA(destDir, lpszFilename, FALSE)) curDir = destDir;
|
||||||
else if(testFileExistenceA(winDir, lpszFilename, FALSE))
|
else if(testFileExistenceA(winDir, lpszFilename, FALSE))
|
||||||
{
|
|
||||||
curDir = winDir;
|
curDir = winDir;
|
||||||
retval |= VFF_CURNEDEST;
|
|
||||||
}
|
|
||||||
else if(testFileExistenceA(systemDir, lpszFilename, FALSE))
|
else if(testFileExistenceA(systemDir, lpszFilename, FALSE))
|
||||||
{
|
|
||||||
curDir = systemDir;
|
curDir = systemDir;
|
||||||
|
|
||||||
|
if (lpszAppDir && lpszAppDir[0])
|
||||||
|
{
|
||||||
|
if(!testFileExistenceA(lpszAppDir, lpszFilename, FALSE))
|
||||||
retval |= VFF_CURNEDEST;
|
retval |= VFF_CURNEDEST;
|
||||||
}
|
}
|
||||||
|
else if(testFileExistenceA(NULL, lpszFilename, FALSE))
|
||||||
|
retval |= VFF_CURNEDEST;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue