forked from enlightenment/efl
* eio: report current operation during progress.
SVN revision: 53063
This commit is contained in:
parent
d85ab417fd
commit
9e019c7227
|
@ -58,16 +58,13 @@
|
||||||
# endif
|
# endif
|
||||||
#endif /* ! _WIN32 */
|
#endif /* ! _WIN32 */
|
||||||
|
|
||||||
typedef enum _Eio_File_Op_Flags
|
typedef enum _Eio_File_Op
|
||||||
{
|
{
|
||||||
EIO_FILE_MOD_TIME = 1,
|
EIO_FILE_COPY,
|
||||||
EIO_FILE_SIZE = 2,
|
EIO_FILE_MOVE,
|
||||||
EIO_FILE_EXISTS = 4,
|
EIO_DIR_COPY,
|
||||||
EIO_FILE_IS_DIR = 8,
|
EIO_DIR_MOVE
|
||||||
EIO_FILE_CAN_READ = 16,
|
} Eio_File_Op;
|
||||||
EIO_FILE_CAN_WRITE = 32,
|
|
||||||
EIO_FILE_CAN_EXECUTE = 64
|
|
||||||
} Eio_File_Op_Flags;
|
|
||||||
|
|
||||||
typedef struct _Eio_File Eio_File;
|
typedef struct _Eio_File Eio_File;
|
||||||
typedef struct _Eio_Progress Eio_Progress;
|
typedef struct _Eio_Progress Eio_Progress;
|
||||||
|
@ -87,6 +84,8 @@ typedef void (*Eio_Error_Cb)(int error, void *data);
|
||||||
|
|
||||||
struct _Eio_Progress
|
struct _Eio_Progress
|
||||||
{
|
{
|
||||||
|
Eio_File_Op op;
|
||||||
|
|
||||||
off_t current;
|
off_t current;
|
||||||
off_t max;
|
off_t max;
|
||||||
float percent;
|
float percent;
|
||||||
|
|
|
@ -283,17 +283,14 @@ _eio_file_copy_splice(Ecore_Thread *thread, Eio_File_Progress *op, int in, int o
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void
|
Eina_Bool
|
||||||
_eio_file_copy_heavy(Ecore_Thread *thread, void *data)
|
eio_file_copy_do(Ecore_Thread *thread, Eio_File_Progress *copy)
|
||||||
{
|
{
|
||||||
Eio_File_Progress *copy;
|
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
int result = -1;
|
int result = -1;
|
||||||
int in = -1;
|
int in = -1;
|
||||||
int out = -1;
|
int out = -1;
|
||||||
|
|
||||||
copy = data;
|
|
||||||
|
|
||||||
in = open(copy->source, O_RDONLY);
|
in = open(copy->source, O_RDONLY);
|
||||||
if (in < 0)
|
if (in < 0)
|
||||||
{
|
{
|
||||||
|
@ -331,7 +328,7 @@ _eio_file_copy_heavy(Ecore_Thread *thread, void *data)
|
||||||
close(out);
|
close(out);
|
||||||
close(in);
|
close(in);
|
||||||
|
|
||||||
return ;
|
return EINA_TRUE;
|
||||||
|
|
||||||
on_error:
|
on_error:
|
||||||
eio_file_thread_error(©->common);
|
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) close(out);
|
||||||
if (out >= 0)
|
if (out >= 0)
|
||||||
unlink(copy->dest);
|
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
|
static void
|
||||||
|
@ -637,6 +642,7 @@ eio_file_copy(const char *source,
|
||||||
copy = malloc(sizeof (Eio_File_Progress));
|
copy = malloc(sizeof (Eio_File_Progress));
|
||||||
if (!copy) return NULL;
|
if (!copy) return NULL;
|
||||||
|
|
||||||
|
move->op = EIO_FILE_COPY;
|
||||||
copy->progress_cb = progress_cb;
|
copy->progress_cb = progress_cb;
|
||||||
copy->source = eina_stringshare_add(source);
|
copy->source = eina_stringshare_add(source);
|
||||||
copy->dest = eina_stringshare_add(dest);
|
copy->dest = eina_stringshare_add(dest);
|
||||||
|
@ -684,6 +690,7 @@ eio_file_move(const char *source,
|
||||||
move = malloc(sizeof (Eio_File_Move));
|
move = malloc(sizeof (Eio_File_Move));
|
||||||
if (!move) return NULL;
|
if (!move) return NULL;
|
||||||
|
|
||||||
|
move->progress.op = EIO_FILE_MOVE;
|
||||||
move->progress.progress_cb = progress_cb;
|
move->progress.progress_cb = progress_cb;
|
||||||
move->progress.source = eina_stringshare_add(source);
|
move->progress.source = eina_stringshare_add(source);
|
||||||
move->progress.dest = eina_stringshare_add(dest);
|
move->progress.dest = eina_stringshare_add(dest);
|
||||||
|
|
|
@ -110,6 +110,7 @@ eio_progress_send(Ecore_Thread *thread, Eio_File_Progress *op, off_t current, of
|
||||||
progress = eio_progress_malloc();
|
progress = eio_progress_malloc();
|
||||||
if (!progress) return ;
|
if (!progress) return ;
|
||||||
|
|
||||||
|
progress->op = op->op;
|
||||||
progress->current = current;
|
progress->current = current;
|
||||||
progress->max = max;
|
progress->max = max;
|
||||||
progress->percent = (float) current * 100.0 / (float) max;
|
progress->percent = (float) current * 100.0 / (float) max;
|
||||||
|
|
|
@ -93,6 +93,8 @@ struct _Eio_File_Progress
|
||||||
|
|
||||||
const char *source;
|
const char *source;
|
||||||
const char *dest;
|
const char *dest;
|
||||||
|
|
||||||
|
Eio_File_Op op;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _Eio_File_Move
|
struct _Eio_File_Move
|
||||||
|
@ -136,5 +138,6 @@ Eio_Progress *eio_progress_malloc(void);
|
||||||
void eio_progress_free(Eio_Progress *progress);
|
void eio_progress_free(Eio_Progress *progress);
|
||||||
void eio_progress_send(Ecore_Thread *thread, Eio_File_Progress *op,
|
void eio_progress_send(Ecore_Thread *thread, Eio_File_Progress *op,
|
||||||
off_t current, off_t max);
|
off_t current, off_t max);
|
||||||
|
Eina_Bool eio_file_copy_do(Ecore_Thread *thread, Eio_File_Progress *copy);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue