eio_dir_copy() tutorial

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files
- Examples

eio_dir_copy() tutorial

To use eio_dir_copy(), you basically need the source and destination files (or directories), and set three callbacks:

- The notification callback, which allows you to know if a file or a directory is copied, and the progress of the copy.
- The end callback, which is called when the copy is finished.
- The error callback, which is called if an error occurred. You can then retrieve the error type as an errno error.

Warning
  It is the user's duty to provide the "right target". It means that copying to '.' will copy the content directly inside '.' and not in a subdirectory.

Here is a simple example:

#include <Ecore.h>
#include <Eio.h>
static void
_test_notify_cb(void *data, Eio_File *handler, const Eio_Progress *info)
{
switch (info->op)
{
case EIO_FILE_COPY:
printf("[%s] %f%%\n", info->dest, info->percent);
break;
case EIO_DIR_COPY:
printf("global [%li/%li] %f%%\n", info->current, info->max, info->percent);
break;
}
}
static void
_test_done_cb(void *data, Eio_File *handler)
{
printf("copy done\n");
ecore_main_loop_quit();
}
static void
_test_error_cb(int error, Eio_File *handler, void *data)
{
fprintf(stderr, "error: [%s]\n", strerror(error));
ecore_main_loop_quit();
}
int
main(int argc, char **argv)
{
Eio_File *cp;
if (argc != 3)
{
fprintf(stderr, "eio_cp source_file destination_file\n");
return -1;
}
ecore_init();
eio_init();
cp = eio_dir_copy(argv[1], argv[2],
_test_notify_cb,
_test_done_cb,
_test_error_cb,
NULL);
ecore_main_loop_begin();
eio_shutdown();
ecore_shutdown();
return 0;
}