forked from enlightenment/efl
eio: convert efl_io_manager_direct_ls to Eina_Future.
This commit is contained in:
parent
da45eb54a8
commit
51776fb94a
|
@ -171,6 +171,23 @@ _future_string_cb(void *data EINA_UNUSED, Eio_File *handler, Eina_Array *gather)
|
|||
}
|
||||
|
||||
/* Direct listing callbacks */
|
||||
static void
|
||||
_future_file_info_cb(void *data EINA_UNUSED, Eio_File *handler, Eina_Array *gather)
|
||||
{
|
||||
EflIoDirectInfo info = ecore_thread_local_data_find(handler->thread, ".info");
|
||||
void *info_data = ecore_thread_local_data_find(handler->thread, ".info_data");
|
||||
Eio_File_Direct_Info *d;
|
||||
|
||||
if (!info) goto end;
|
||||
|
||||
info(info_data, gather);
|
||||
|
||||
end:
|
||||
while ((d = eina_array_pop(gather)))
|
||||
eio_direct_info_free(d);
|
||||
eina_array_free(gather);
|
||||
}
|
||||
|
||||
static void
|
||||
_file_info_cb(void *data, Eio_File *handler, Eina_Array *gather)
|
||||
{
|
||||
|
@ -213,44 +230,47 @@ _file_info_cb(void *data, Eio_File *handler, Eina_Array *gather)
|
|||
}
|
||||
|
||||
/* Method implementations */
|
||||
static Efl_Future *
|
||||
static Eina_Future *
|
||||
_efl_io_manager_direct_ls(Eo *obj,
|
||||
Efl_Io_Manager_Data *pd EINA_UNUSED,
|
||||
const char *path,
|
||||
Eina_Bool recursive)
|
||||
Eina_Bool recursive,
|
||||
void *info_data, EflIoDirectInfo info, Eina_Free_Cb info_free_cb)
|
||||
{
|
||||
Efl_Promise *p;
|
||||
Eina_Promise *p;
|
||||
Eina_Future *future;
|
||||
Eio_File *h;
|
||||
|
||||
Eo *loop = efl_loop_get(obj);
|
||||
p = efl_add(EFL_PROMISE_CLASS, loop);
|
||||
p = efl_loop_promise_new(obj, _efl_io_manager_future_cancel, NULL);
|
||||
if (!p) return NULL;
|
||||
future = eina_future_new(p);
|
||||
|
||||
if (!recursive)
|
||||
{
|
||||
h = _eio_file_direct_ls(path,
|
||||
_file_info_cb,
|
||||
_file_done_cb,
|
||||
_file_error_cb,
|
||||
_future_file_info_cb,
|
||||
_future_file_done_cb,
|
||||
_future_file_error_cb,
|
||||
p);
|
||||
}
|
||||
else
|
||||
{
|
||||
h = _eio_dir_direct_ls(path,
|
||||
_file_info_cb,
|
||||
_file_done_cb,
|
||||
_file_error_cb,
|
||||
_future_file_info_cb,
|
||||
_future_file_done_cb,
|
||||
_future_file_error_cb,
|
||||
p);
|
||||
}
|
||||
|
||||
if (!h) goto end;
|
||||
|
||||
efl_event_callback_array_add(p, promise_progress_handling(), h);
|
||||
return efl_promise_future_get(p);
|
||||
ecore_thread_local_data_add(h->thread, ".info", info, NULL, EINA_TRUE);
|
||||
ecore_thread_local_data_add(h->thread, ".info_data", info_data, info_free_cb, EINA_TRUE);
|
||||
eina_promise_data_set(p, h);
|
||||
|
||||
return efl_future_Eina_FutureXXX_then(obj, future);
|
||||
|
||||
end:
|
||||
efl_del(p);
|
||||
return NULL;
|
||||
return future;
|
||||
}
|
||||
|
||||
static Efl_Future *
|
||||
|
|
|
@ -42,8 +42,9 @@ class Efl.Io.Manager (Efl.Loop_Consumer)
|
|||
params {
|
||||
@in path: string;[[Path we want to list entries for]]
|
||||
@in recursive: bool; [[If $true, list entries recursively, $false otherwise]]
|
||||
info: EflIoDirectInfo; [[Callback called for each packet of @Eina.File.Direct.Info]]
|
||||
}
|
||||
return: future<uint64, const(array<ptr(Eina.File.Direct.Info)>)>; [[List of entries in path]]
|
||||
return: ptr(Eina.Future) @owned; [[Amount of files found during the listing of the directory]]
|
||||
}
|
||||
|
||||
stat_ls {
|
||||
|
|
Loading…
Reference in New Issue