37 #if defined(LP_SYS_WINCE) && !defined(FindFirstFile)
38 # define FindFirstFile FindFirstFileW
40 #if defined(LP_SYS_WINCE) && !defined(FindFirstFile)
41 # define FindNextFile FindNextFileW
57 if (ctx == NULL || directory == NULL)
74 if (
sizeof(TCHAR) !=
sizeof(
char))
78 size_t index = 0,len_0 = strlen(directory) + 1;
80 wdir = (TCHAR *)malloc(len_0 *
sizeof(TCHAR));
89 #ifdef LP_MULTIBYTE_AVAILABLE
90 if (!MultiByteToWideChar(CP_ACP, 0, directory, len_0, (WCHAR *)wdir, len_0))
92 for (index = 0; index < len_0; index++)
93 wdir[index] = (TCHAR)directory[index];
95 (*ctx)->handle = FindFirstFile(wdir, &(*ctx)->ctx);
100 (*ctx)->handle = FindFirstFile((TCHAR *)directory, &(*ctx)->ctx);
102 if ((*ctx)->handle == INVALID_HANDLE_VALUE)
112 if (FindNextFile((*ctx)->handle, &(*ctx)->ctx) == FALSE)
118 if (
sizeof(TCHAR) !=
sizeof(
char))
120 TCHAR *wdir = (*ctx)->ctx.cFileName;
121 size_t index, len_0 = 0;
123 while (wdir[len_0] && len_0 < (
sizeof((*ctx)->entry_name) - 1)) len_0++;
126 #ifdef LP_MULTIBYTE_AVAILABLE
127 if (!WideCharToMultiByte(CP_ACP, 0, (WCHAR *)wdir, len_0, (*ctx)->entry_name,
128 sizeof((*ctx)->entry_name), NULL, 0))
130 for (index = 0; index < len_0; index++)
131 (*ctx)->entry_name[index] = (
char)wdir[index];
134 strncpy((*ctx)->entry_name, (
const char *)(*ctx)->ctx.cFileName,
135 sizeof((*ctx)->entry_name)-1);
137 (*ctx)->entry_name[
sizeof((*ctx)->entry_name)-1] =
'\0';
139 return (*ctx)->entry_name;
144 if (ctx != NULL && *ctx != NULL)
146 FindClose((*ctx)->handle);