6#include <winpr/tchar.h>
7#include <winpr/windows.h>
9static TCHAR testDirectory2File1[] = _T(
"TestDirectory2File1");
10static TCHAR testDirectory2File2[] = _T(
"TestDirectory2File2");
12int TestFileFindNextFile(
int argc,
char* argv[])
17 HANDLE hFind =
nullptr;
18 LPTSTR BasePath =
nullptr;
19 WIN32_FIND_DATA FindData;
20 TCHAR FilePath[PATHCCH_MAX_CCH] = WINPR_C_ARRAY_INIT;
24 BasePath = ConvertUtf8ToWChar(str, &length);
28 _tprintf(_T(
"Unable to allocate memory"));
32 BasePath = _strdup(str);
36 printf(
"Unable to allocate memory");
40 length = strlen(BasePath);
43 CopyMemory(FilePath, BasePath, length *
sizeof(TCHAR));
45 if (FAILED(PathCchConvertStyle(BasePath, length, PATH_STYLE_WINDOWS)))
47 if (FAILED(NativePathCchAppend(FilePath, PATHCCH_MAX_CCH, _T(
"TestDirectory2"))))
49 if (FAILED(NativePathCchAppend(FilePath, PATHCCH_MAX_CCH, _T(
"TestDirectory2File*"))))
52 _tprintf(_T(
"Finding file: %s\n"), FilePath);
53 hFind = FindFirstFile(FilePath, &FindData);
55 if (hFind == INVALID_HANDLE_VALUE)
57 _tprintf(_T(
"FindFirstFile failure: %s\n"), FilePath);
61 _tprintf(_T(
"FindFirstFile: %s"), FindData.cFileName);
67 if ((_tcsncmp(FindData.cFileName, testDirectory2File1, ARRAYSIZE(testDirectory2File1)) != 0) &&
68 (_tcsncmp(FindData.cFileName, testDirectory2File2, ARRAYSIZE(testDirectory2File2)) != 0))
70 _tprintf(_T(
"FindFirstFile failure: Expected: %s, Actual: %s\n"), testDirectory2File1,
75 status = FindNextFile(hFind, &FindData);
79 _tprintf(_T(
"FindNextFile failure: Expected: TRUE, Actual: %") _T(PRId32) _T(
"\n"), status);
83 if ((_tcsncmp(FindData.cFileName, testDirectory2File1, ARRAYSIZE(testDirectory2File1)) != 0) &&
84 (_tcsncmp(FindData.cFileName, testDirectory2File2, ARRAYSIZE(testDirectory2File2)) != 0))
86 _tprintf(_T(
"FindNextFile failure: Expected: %s, Actual: %s\n"), testDirectory2File2,
91 status = FindNextFile(hFind, &FindData);
95 _tprintf(_T(
"FindNextFile failure: Expected: FALSE, Actual: %") _T(PRId32) _T(
"\n"),