4 #include <winpr/file.h>
5 #include <winpr/path.h>
6 #include <winpr/tchar.h>
7 #include <winpr/windows.h>
9 static TCHAR testDirectory2File1[] = _T(
"TestDirectory2File1");
10 static TCHAR testDirectory2File2[] = _T(
"TestDirectory2File2");
12 int TestFileFindNextFile(
int argc,
char* argv[])
18 LPTSTR BasePath = NULL;
19 WIN32_FIND_DATA FindData;
20 TCHAR FilePath[PATHCCH_MAX_CCH] = { 0 };
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 PathCchConvertStyle(BasePath, length, PATH_STYLE_WINDOWS);
46 NativePathCchAppend(FilePath, PATHCCH_MAX_CCH, _T(
"TestDirectory2"));
47 NativePathCchAppend(FilePath, PATHCCH_MAX_CCH, _T(
"TestDirectory2File*"));
49 _tprintf(_T(
"Finding file: %s\n"), FilePath);
50 hFind = FindFirstFile(FilePath, &FindData);
52 if (hFind == INVALID_HANDLE_VALUE)
54 _tprintf(_T(
"FindFirstFile failure: %s\n"), FilePath);
58 _tprintf(_T(
"FindFirstFile: %s"), FindData.cFileName);
64 if ((_tcsncmp(FindData.cFileName, testDirectory2File1, ARRAYSIZE(testDirectory2File1)) != 0) &&
65 (_tcsncmp(FindData.cFileName, testDirectory2File2, ARRAYSIZE(testDirectory2File2)) != 0))
67 _tprintf(_T(
"FindFirstFile failure: Expected: %s, Actual: %s\n"), testDirectory2File1,
72 status = FindNextFile(hFind, &FindData);
76 _tprintf(_T(
"FindNextFile failure: Expected: TRUE, Actual: %") _T(PRId32) _T(
"\n"), status);
80 if ((_tcsncmp(FindData.cFileName, testDirectory2File1, ARRAYSIZE(testDirectory2File1)) != 0) &&
81 (_tcsncmp(FindData.cFileName, testDirectory2File2, ARRAYSIZE(testDirectory2File2)) != 0))
83 _tprintf(_T(
"FindNextFile failure: Expected: %s, Actual: %s\n"), testDirectory2File2,
88 status = FindNextFile(hFind, &FindData);
92 _tprintf(_T(
"FindNextFile failure: Expected: FALSE, Actual: %") _T(PRId32) _T(
"\n"),