2016-04-12 12:00:23 -07:00
|
|
|
#if HAVE_CONFIG_H
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
|
|
|
|
2017-03-09 13:18:10 -08:00
|
|
|
#include <inttypes.h>
|
2016-04-12 12:00:23 -07:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include <Eina.h>
|
|
|
|
#include <Eio.h>
|
|
|
|
#include <Ecore.h>
|
|
|
|
|
2017-10-05 14:21:23 -07:00
|
|
|
static Eina_Value
|
|
|
|
done_cb(void *data EINA_UNUSED,
|
|
|
|
const Eina_Value file,
|
|
|
|
const Eina_Future *dead EINA_UNUSED)
|
2016-04-12 12:00:23 -07:00
|
|
|
{
|
2017-10-05 14:21:23 -07:00
|
|
|
if (file.type == EINA_VALUE_TYPE_ERROR)
|
|
|
|
{
|
|
|
|
Eina_Error err;
|
2016-04-12 12:00:23 -07:00
|
|
|
|
2017-10-05 14:21:23 -07:00
|
|
|
eina_value_get(&file, &err);
|
|
|
|
fprintf(stderr, "Something has gone wrong: %s\n", eina_error_msg_get(err));
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
if (file.type == EINA_VALUE_TYPE_UINT64)
|
|
|
|
{
|
|
|
|
uint64_t value;
|
2016-04-12 12:00:23 -07:00
|
|
|
|
2017-10-05 14:21:23 -07:00
|
|
|
eina_value_get(&file, &value);
|
2016-09-09 16:22:20 -07:00
|
|
|
|
2020-05-07 06:27:07 -07:00
|
|
|
printf("%s done listing files %"PRIu64".\n", __func__, value);
|
2017-10-05 14:21:23 -07:00
|
|
|
}
|
2016-04-12 12:00:23 -07:00
|
|
|
|
2017-10-05 14:21:23 -07:00
|
|
|
ecore_main_loop_quit();
|
2016-04-12 12:00:23 -07:00
|
|
|
|
2017-10-05 14:21:23 -07:00
|
|
|
return file;
|
2016-04-12 12:00:23 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Progress used to be the "Eio_Main_Cb" family of callbacks in the legacy API.
|
2017-10-05 14:21:23 -07:00
|
|
|
static void
|
2018-04-30 10:06:47 -07:00
|
|
|
progress_cb(void *data EINA_UNUSED, Eina_Array *array)
|
2016-04-12 12:00:23 -07:00
|
|
|
{
|
2018-04-30 10:06:47 -07:00
|
|
|
Eina_Array_Iterator it;
|
2016-09-09 16:22:20 -07:00
|
|
|
const char *filename;
|
2017-10-05 14:21:23 -07:00
|
|
|
unsigned int count;
|
2016-09-09 16:22:20 -07:00
|
|
|
|
2018-04-30 10:06:47 -07:00
|
|
|
EINA_ARRAY_ITER_NEXT(array, count, filename, it)
|
2020-05-07 06:27:07 -07:00
|
|
|
printf("%s listing filename: %s\n", __func__, filename);
|
2016-04-12 12:00:23 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void list_files(void *data)
|
|
|
|
{
|
2018-02-26 21:10:12 -08:00
|
|
|
Efl_Io_Manager *job = efl_add(EFL_IO_MANAGER_CLASS, efl_main_loop_get());
|
2016-09-09 16:22:20 -07:00
|
|
|
const char *path = data;
|
|
|
|
|
2017-10-05 14:21:23 -07:00
|
|
|
eina_future_then(efl_io_manager_ls(job, path, NULL, progress_cb, NULL), done_cb, NULL);
|
2016-04-12 12:00:23 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char const *argv[])
|
|
|
|
{
|
2016-09-09 16:22:20 -07:00
|
|
|
const char *path;
|
|
|
|
|
|
|
|
eio_init();
|
|
|
|
ecore_init();
|
2016-04-12 12:00:23 -07:00
|
|
|
|
2016-09-09 16:22:20 -07:00
|
|
|
path = getenv("HOME");
|
2016-04-12 12:00:23 -07:00
|
|
|
|
2016-09-09 16:22:20 -07:00
|
|
|
if (argc > 1)
|
|
|
|
path = argv[1];
|
2016-04-12 12:00:23 -07:00
|
|
|
|
2018-12-29 04:11:30 -08:00
|
|
|
ecore_job_add(&list_files, path);
|
2016-04-12 12:00:23 -07:00
|
|
|
|
2016-09-09 16:22:20 -07:00
|
|
|
ecore_main_loop_begin();
|
2016-04-12 12:00:23 -07:00
|
|
|
|
2016-09-09 16:22:20 -07:00
|
|
|
ecore_shutdown();
|
|
|
|
eio_shutdown();
|
|
|
|
return 0;
|
2016-04-12 12:00:23 -07:00
|
|
|
}
|