6#include <winpr/tchar.h>
7#include <winpr/windows.h>
9#define TEST_MAX_PATH 4096
11static TCHAR testDirectory2File1[] = _T(
"TestDirectory2File1");
12static TCHAR testDirectory2File2[] = _T(
"TestDirectory2File2");
14int TestFileFindNextFile(
int argc,
char* argv[])
19 HANDLE hFind =
nullptr;
20 LPTSTR BasePath =
nullptr;
21 WIN32_FIND_DATA FindData;
22 TCHAR FilePath[TEST_MAX_PATH] = WINPR_C_ARRAY_INIT;
26 BasePath = ConvertUtf8ToWChar(str, &length);
30 _tprintf(_T(
"Unable to allocate memory"));
34 BasePath = _strdup(str);
38 printf(
"Unable to allocate memory");
42 length = strlen(BasePath);
45 CopyMemory(FilePath, BasePath, length *
sizeof(TCHAR));
47 if (FAILED(PathCchConvertStyle(BasePath, length, PATH_STYLE_WINDOWS)))
49 if (FAILED(NativePathCchAppend(FilePath, ARRAYSIZE(FilePath), _T(
"TestDirectory2"))))
51 if (FAILED(NativePathCchAppend(FilePath, ARRAYSIZE(FilePath), _T(
"TestDirectory2File*"))))
54 _tprintf(_T(
"Finding file: %s\n"), FilePath);
55 hFind = FindFirstFile(FilePath, &FindData);
57 if (hFind == INVALID_HANDLE_VALUE)
59 _tprintf(_T(
"FindFirstFile failure: %s\n"), FilePath);
63 _tprintf(_T(
"FindFirstFile: %s"), FindData.cFileName);
69 if ((_tcsncmp(FindData.cFileName, testDirectory2File1, ARRAYSIZE(testDirectory2File1)) != 0) &&
70 (_tcsncmp(FindData.cFileName, testDirectory2File2, ARRAYSIZE(testDirectory2File2)) != 0))
72 _tprintf(_T(
"FindFirstFile failure: Expected: %s, Actual: %s\n"), testDirectory2File1,
77 status = FindNextFile(hFind, &FindData);
81 _tprintf(_T(
"FindNextFile failure: Expected: TRUE, Actual: %") _T(PRId32) _T(
"\n"), status);
85 if ((_tcsncmp(FindData.cFileName, testDirectory2File1, ARRAYSIZE(testDirectory2File1)) != 0) &&
86 (_tcsncmp(FindData.cFileName, testDirectory2File2, ARRAYSIZE(testDirectory2File2)) != 0))
88 _tprintf(_T(
"FindNextFile failure: Expected: %s, Actual: %s\n"), testDirectory2File2,
93 status = FindNextFile(hFind, &FindData);
97 _tprintf(_T(
"FindNextFile failure: Expected: FALSE, Actual: %") _T(PRId32) _T(
"\n"),