summaryrefslogtreecommitdiff
path: root/src/examples/eio/eio_file_copy.c
blob: 72da1b7e4bbc740f142bae0aab9500a6d51305ef (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//Compile with:
//gcc -o eio_file_copy eio_file_copy.c `pkg-config --cflags --libs ecore eio`

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <Eio.h>
#include <Ecore.h>

static void
_progress_cb(void *data EINA_UNUSED, Eio_File *handle EINA_UNUSED, const Eio_Progress *info)
{
   printf("progress: %5lld/%lld (%3.0f%%)\n", info->current, info->max,
          info->percent);
}

static void
_done_cb(void *data EINA_UNUSED, Eio_File *handle EINA_UNUSED)
{
   puts("Successfully finished copy");
   ecore_main_loop_quit();
}

static void
_error_cb(void *data EINA_UNUSED, Eio_File *handle EINA_UNUSED, int error)
{
   fprintf(stderr, "Something wrong has happend:%s\n", strerror(error));
   ecore_main_loop_quit();
}

int
main(int argc, char **argv)
{
   if (argc != 3)
     {
        fprintf(stderr, "Usage: %s <src> <dst>\n", argv[0]);
        return  EXIT_FAILURE;
     }

   ecore_init();
   eio_init();

   eio_file_copy(argv[1], argv[2], _progress_cb, _done_cb, _error_cb, NULL);

   ecore_main_loop_begin();

   eio_shutdown();
   ecore_shutdown();

   return 0;
}