forked from enlightenment/efl
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:
parent
a3f8ec0e0c
commit
15ca789692
|
@ -91,7 +91,12 @@ _feedback_job(void *data, Ecore_Thread *th)
|
||||||
time_t t;
|
time_t t;
|
||||||
int i, count;
|
int i, count;
|
||||||
Feedback_Thread_Data *ftd = NULL;
|
Feedback_Thread_Data *ftd = NULL;
|
||||||
|
#ifdef _WIN32
|
||||||
|
HANDLE h;
|
||||||
|
WIN32_FIND_DATA fd;
|
||||||
|
#else
|
||||||
DIR *dir;
|
DIR *dir;
|
||||||
|
#endif
|
||||||
App_Msg *msg;
|
App_Msg *msg;
|
||||||
|
|
||||||
count = (int)ecore_thread_global_data_find("count");
|
count = (int)ecore_thread_global_data_find("count");
|
||||||
|
@ -110,15 +115,27 @@ _feedback_job(void *data, Ecore_Thread *th)
|
||||||
if (!ftd)
|
if (!ftd)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
h = FindFirstFile(ftd->base, &fd);
|
||||||
|
if (h == INVALID_HANDLE_VALUE)
|
||||||
|
goto the_end;
|
||||||
|
#else
|
||||||
dir = opendir(ftd->base);
|
dir = opendir(ftd->base);
|
||||||
if (!dir)
|
if (!dir)
|
||||||
goto the_end;
|
goto the_end;
|
||||||
|
#endif
|
||||||
|
|
||||||
msg = calloc(1, sizeof(App_Msg));
|
msg = calloc(1, sizeof(App_Msg));
|
||||||
|
|
||||||
t = time(NULL);
|
t = time(NULL);
|
||||||
while (time(NULL) < t + 2)
|
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;
|
struct dirent entry, *result;
|
||||||
|
|
||||||
if (readdir_r(dir, &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)
|
if (strlen(result->d_name) >= 10)
|
||||||
msg->list = eina_list_append(msg->list,
|
msg->list = eina_list_append(msg->list,
|
||||||
strdup(result->d_name));
|
strdup(result->d_name));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
FindClose(h);
|
||||||
|
#else
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
|
#endif
|
||||||
ecore_thread_feedback(th, msg);
|
ecore_thread_feedback(th, msg);
|
||||||
|
|
||||||
the_end:
|
the_end:
|
||||||
|
|
Loading…
Reference in New Issue