ecore: use WIN32 API to port readdir_r in ecore thread example

Signed-off-by: Cedric BAIL <cedric.bail@samsung.com>
This commit is contained in:
Vincent Torri 2014-01-09 07:55:17 +01:00 committed by Cedric BAIL
parent a3f8ec0e0c
commit 15ca789692
1 changed files with 22 additions and 0 deletions

View File

@ -91,7 +91,12 @@ _feedback_job(void *data, Ecore_Thread *th)
time_t t;
int i, count;
Feedback_Thread_Data *ftd = NULL;
#ifdef _WIN32
HANDLE h;
WIN32_FIND_DATA fd;
#else
DIR *dir;
#endif
App_Msg *msg;
count = (int)ecore_thread_global_data_find("count");
@ -110,15 +115,27 @@ _feedback_job(void *data, Ecore_Thread *th)
if (!ftd)
return;
#ifdef _WIN32
h = FindFirstFile(ftd->base, &fd);
if (h == INVALID_HANDLE_VALUE)
goto the_end;
#else
dir = opendir(ftd->base);
if (!dir)
goto the_end;
#endif
msg = calloc(1, sizeof(App_Msg));
t = time(NULL);
while (time(NULL) < t + 2)
{
#ifdef _WIN32
if (strlen(fd.cFileName) >= 10)
msg->list = eina_list_append(msg->list,
strdup(fd.cFileName));
FindNextFile(h, &fd);
#else
struct dirent entry, *result;
if (readdir_r(dir, &entry, &result))
@ -129,9 +146,14 @@ _feedback_job(void *data, Ecore_Thread *th)
if (strlen(result->d_name) >= 10)
msg->list = eina_list_append(msg->list,
strdup(result->d_name));
#endif
}
#ifdef _WIN32
FindClose(h);
#else
closedir(dir);
#endif
ecore_thread_feedback(th, msg);
the_end: