efl: add eina_file_copy()
it's useful to copy file from one place to another and this will be used in eio' s implementation. NOTE: did not use mmap here as mmap faults may be cumbersome to handle (Eina_File itself does that, but in a nasty way) and the implementation would be severely different as there is no Eina_File from FD, and there is no way to inject custom memory/fd into the Eina_File's fault handling. The performance would not be that different anyways and the splice() is already in there for systems with good performance (read: Linux). SVN revision: 81942
This commit is contained in:
parent
65012fa66d
commit
a06b26817c
|
@ -13,6 +13,7 @@ eina_array_01.c \
|
|||
eina_array_02.c \
|
||||
eina_error_01.c \
|
||||
eina_file_01.c \
|
||||
eina_file_02.c \
|
||||
eina_hash_01.c \
|
||||
eina_hash_02.c \
|
||||
eina_hash_03.c \
|
||||
|
@ -56,6 +57,7 @@ eina_array_01 \
|
|||
eina_array_02 \
|
||||
eina_error_01 \
|
||||
eina_file_01 \
|
||||
eina_file_02 \
|
||||
eina_hash_01 \
|
||||
eina_hash_02 \
|
||||
eina_hash_03 \
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
//Compile with:
|
||||
//gcc -g eina_file_02.c -o eina_file_02 `pkg-config --cflags --libs eina`
|
||||
|
||||
#include <stdio.h>
|
||||
#include <Eina.h>
|
||||
|
||||
static Eina_Bool
|
||||
_progress_cb(void *data, unsigned long long done, unsigned long long total)
|
||||
{
|
||||
const char **files = data;
|
||||
printf("%5llu/%llu of copy '%s' to '%s'\n", done, total, files[0], files[1]);
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
Eina_Bool ret;
|
||||
|
||||
if (argc != 3)
|
||||
{
|
||||
fprintf(stderr, "Usage: %s <src> <dst>\n", argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
eina_init();
|
||||
|
||||
ret = eina_file_copy(argv[1], argv[2],
|
||||
EINA_FILE_COPY_PERMISSION | EINA_FILE_COPY_XATTR,
|
||||
_progress_cb, argv + 1);
|
||||
|
||||
printf("copy finished: %s\n", ret ? "success" : "failure");
|
||||
|
||||
eina_shutdown();
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue