summaryrefslogtreecommitdiff
path: root/src/examples
diff options
context:
space:
mode:
authorVincent Torri <vincent.torri@gmail.com>2014-01-09 07:55:17 +0100
committerCedric BAIL <cedric.bail@samsung.com>2014-01-10 16:35:18 +0900
commit15ca7896929b0d0e64f996a8c7c6d0ae76219eda (patch)
treedf89839a57547dfbff451bf5239886390dfa8c2a /src/examples
parenta3f8ec0e0cfd3df478ccc0cc2195d99639778e5f (diff)
ecore: use WIN32 API to port readdir_r in ecore thread example
Signed-off-by: Cedric BAIL <cedric.bail@samsung.com>
Diffstat (limited to 'src/examples')
-rw-r--r--src/examples/ecore/ecore_thread_example.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/examples/ecore/ecore_thread_example.c b/src/examples/ecore/ecore_thread_example.c
index 74cbffbb67..74cf386a50 100644
--- a/src/examples/ecore/ecore_thread_example.c
+++ b/src/examples/ecore/ecore_thread_example.c
@@ -91,7 +91,12 @@ _feedback_job(void *data, Ecore_Thread *th)
91 time_t t; 91 time_t t;
92 int i, count; 92 int i, count;
93 Feedback_Thread_Data *ftd = NULL; 93 Feedback_Thread_Data *ftd = NULL;
94#ifdef _WIN32
95 HANDLE h;
96 WIN32_FIND_DATA fd;
97#else
94 DIR *dir; 98 DIR *dir;
99#endif
95 App_Msg *msg; 100 App_Msg *msg;
96 101
97 count = (int)ecore_thread_global_data_find("count"); 102 count = (int)ecore_thread_global_data_find("count");
@@ -110,15 +115,27 @@ _feedback_job(void *data, Ecore_Thread *th)
110 if (!ftd) 115 if (!ftd)
111 return; 116 return;
112 117
118#ifdef _WIN32
119 h = FindFirstFile(ftd->base, &fd);
120 if (h == INVALID_HANDLE_VALUE)
121 goto the_end;
122#else
113 dir = opendir(ftd->base); 123 dir = opendir(ftd->base);
114 if (!dir) 124 if (!dir)
115 goto the_end; 125 goto the_end;
126#endif
116 127
117 msg = calloc(1, sizeof(App_Msg)); 128 msg = calloc(1, sizeof(App_Msg));
118 129
119 t = time(NULL); 130 t = time(NULL);
120 while (time(NULL) < t + 2) 131 while (time(NULL) < t + 2)
121 { 132 {
133#ifdef _WIN32
134 if (strlen(fd.cFileName) >= 10)
135 msg->list = eina_list_append(msg->list,
136 strdup(fd.cFileName));
137 FindNextFile(h, &fd);
138#else
122 struct dirent entry, *result; 139 struct dirent entry, *result;
123 140
124 if (readdir_r(dir, &entry, &result)) 141 if (readdir_r(dir, &entry, &result))
@@ -129,9 +146,14 @@ _feedback_job(void *data, Ecore_Thread *th)
129 if (strlen(result->d_name) >= 10) 146 if (strlen(result->d_name) >= 10)
130 msg->list = eina_list_append(msg->list, 147 msg->list = eina_list_append(msg->list,
131 strdup(result->d_name)); 148 strdup(result->d_name));
149#endif
132 } 150 }
133 151
152#ifdef _WIN32
153 FindClose(h);
154#else
134 closedir(dir); 155 closedir(dir);
156#endif
135 ecore_thread_feedback(th, msg); 157 ecore_thread_feedback(th, msg);
136 158
137the_end: 159the_end: