diff --git a/legacy/eio/src/lib/Eio.h b/legacy/eio/src/lib/Eio.h index eb8e4a4275..a456132449 100644 --- a/legacy/eio/src/lib/Eio.h +++ b/legacy/eio/src/lib/Eio.h @@ -58,16 +58,13 @@ # endif #endif /* ! _WIN32 */ -typedef enum _Eio_File_Op_Flags +typedef enum _Eio_File_Op { - EIO_FILE_MOD_TIME = 1, - EIO_FILE_SIZE = 2, - EIO_FILE_EXISTS = 4, - EIO_FILE_IS_DIR = 8, - EIO_FILE_CAN_READ = 16, - EIO_FILE_CAN_WRITE = 32, - EIO_FILE_CAN_EXECUTE = 64 -} Eio_File_Op_Flags; + EIO_FILE_COPY, + EIO_FILE_MOVE, + EIO_DIR_COPY, + EIO_DIR_MOVE +} Eio_File_Op; typedef struct _Eio_File Eio_File; typedef struct _Eio_Progress Eio_Progress; @@ -87,6 +84,8 @@ typedef void (*Eio_Error_Cb)(int error, void *data); struct _Eio_Progress { + Eio_File_Op op; + off_t current; off_t max; float percent; diff --git a/legacy/eio/src/lib/eio_file.c b/legacy/eio/src/lib/eio_file.c index 375ebb1f94..d5b3b0ac40 100644 --- a/legacy/eio/src/lib/eio_file.c +++ b/legacy/eio/src/lib/eio_file.c @@ -283,17 +283,14 @@ _eio_file_copy_splice(Ecore_Thread *thread, Eio_File_Progress *op, int in, int o } #endif -static void -_eio_file_copy_heavy(Ecore_Thread *thread, void *data) +Eina_Bool +eio_file_copy_do(Ecore_Thread *thread, Eio_File_Progress *copy) { - Eio_File_Progress *copy; struct stat buf; int result = -1; int in = -1; int out = -1; - copy = data; - in = open(copy->source, O_RDONLY); if (in < 0) { @@ -331,7 +328,7 @@ _eio_file_copy_heavy(Ecore_Thread *thread, void *data) close(out); close(in); - return ; + return EINA_TRUE; on_error: eio_file_thread_error(©->common); @@ -340,7 +337,15 @@ _eio_file_copy_heavy(Ecore_Thread *thread, void *data) if (out >= 0) close(out); if (out >= 0) unlink(copy->dest); - return ; + return EINA_FALSE; +} + +static void +_eio_file_copy_heavy(Ecore_Thread *thread, void *data) +{ + Eio_File_Progress *copy = data; + + eio_file_copy_do(thread, copy); } static void @@ -637,6 +642,7 @@ eio_file_copy(const char *source, copy = malloc(sizeof (Eio_File_Progress)); if (!copy) return NULL; + move->op = EIO_FILE_COPY; copy->progress_cb = progress_cb; copy->source = eina_stringshare_add(source); copy->dest = eina_stringshare_add(dest); @@ -684,6 +690,7 @@ eio_file_move(const char *source, move = malloc(sizeof (Eio_File_Move)); if (!move) return NULL; + move->progress.op = EIO_FILE_MOVE; move->progress.progress_cb = progress_cb; move->progress.source = eina_stringshare_add(source); move->progress.dest = eina_stringshare_add(dest); diff --git a/legacy/eio/src/lib/eio_main.c b/legacy/eio/src/lib/eio_main.c index 528565bd6f..fe89a517c1 100644 --- a/legacy/eio/src/lib/eio_main.c +++ b/legacy/eio/src/lib/eio_main.c @@ -110,6 +110,7 @@ eio_progress_send(Ecore_Thread *thread, Eio_File_Progress *op, off_t current, of progress = eio_progress_malloc(); if (!progress) return ; + progress->op = op->op; progress->current = current; progress->max = max; progress->percent = (float) current * 100.0 / (float) max; diff --git a/legacy/eio/src/lib/eio_private.h b/legacy/eio/src/lib/eio_private.h index d9a349e47b..d4d8ab30d0 100644 --- a/legacy/eio/src/lib/eio_private.h +++ b/legacy/eio/src/lib/eio_private.h @@ -93,6 +93,8 @@ struct _Eio_File_Progress const char *source; const char *dest; + + Eio_File_Op op; }; struct _Eio_File_Move @@ -136,5 +138,6 @@ Eio_Progress *eio_progress_malloc(void); void eio_progress_free(Eio_Progress *progress); void eio_progress_send(Ecore_Thread *thread, Eio_File_Progress *op, off_t current, off_t max); +Eina_Bool eio_file_copy_do(Ecore_Thread *thread, Eio_File_Progress *copy); #endif