4
#include <winpr/file.h>
5
#include <winpr/path.h>
6
#include <winpr/tchar.h>
7
#include <winpr/windows.h>
9
static TCHAR testFile1[] = _T("TestFile1");
11
int TestFileFindFirstFile(int argc, char* argv[])
17
WIN32_FIND_DATA FindData;
18
TCHAR FilePath[PATHCCH_MAX_CCH];
23
length = MultiByteToWideChar(CP_UTF8, 0, str, strlen(str), NULL, 0);
24
BasePath = (WCHAR*) malloc((length + 1) * sizeof(WCHAR));
25
MultiByteToWideChar(CP_UTF8, 0, str, length, (LPWSTR) BasePath, length * sizeof(WCHAR));
28
BasePath = _strdup(str);
29
length = strlen(BasePath);
32
CopyMemory(FilePath, BasePath, length * sizeof(TCHAR));
35
PathCchConvertStyle(BasePath, length, PATH_STYLE_WINDOWS);
36
NativePathCchAppend(FilePath, PATHCCH_MAX_CCH, _T("TestFile1"));
38
_tprintf(_T("Finding file: %s\n"), FilePath);
40
hFind = FindFirstFile(FilePath, &FindData);
42
if (hFind == INVALID_HANDLE_VALUE)
44
_tprintf(_T("FindFirstFile failure: %s (INVALID_HANDLE_VALUE -1)\n"), FilePath);
48
_tprintf(_T("FindFirstFile: %s"), FindData.cFileName);
50
if (_tcscmp(FindData.cFileName, testFile1) != 0)
52
_tprintf(_T("FindFirstFile failure: Expected: %s, Actual: %s\n"),
53
testFile1, FindData.cFileName);