eio: add eio_file_container_get.

SVN revision: 59646
This commit is contained in:
Cedric BAIL 2011-05-24 10:41:37 +00:00
parent 2600ac9160
commit d41e80a29c
5 changed files with 41 additions and 0 deletions

View File

@ -229,6 +229,8 @@ EAPI Eio_File *eio_dir_unlink(const char *path,
Eio_Error_Cb error_cb, Eio_Error_Cb error_cb,
const void *data); const void *data);
EAPI void *eio_file_container_get(Eio_File *ls);
EAPI Eina_Bool eio_file_cancel(Eio_File *ls); EAPI Eina_Bool eio_file_cancel(Eio_File *ls);
/** /**

View File

@ -239,6 +239,8 @@ _eio_file_recursiv_ls(Ecore_Thread *thread,
return EINA_FALSE; return EINA_FALSE;
} }
eio_file_container_set(common, eina_iterator_container_get(it));
EINA_ITERATOR_FOREACH(it, info) EINA_ITERATOR_FOREACH(it, info)
{ {
Eina_Bool filter = EINA_TRUE; Eina_Bool filter = EINA_TRUE;
@ -264,6 +266,8 @@ _eio_file_recursiv_ls(Ecore_Thread *thread,
goto on_error; goto on_error;
} }
eio_file_container_set(common, NULL);
eina_iterator_free(it); eina_iterator_free(it);
it = NULL; it = NULL;

View File

@ -131,6 +131,8 @@ _eio_file_heavy(void *data, Ecore_Thread *thread)
return ; return ;
} }
eio_file_container_set(&async->ls.common, eina_iterator_container_get(ls));
EINA_ITERATOR_FOREACH(ls, file) EINA_ITERATOR_FOREACH(ls, file)
{ {
Eina_Bool filter = EINA_TRUE; Eina_Bool filter = EINA_TRUE;
@ -147,6 +149,8 @@ _eio_file_heavy(void *data, Ecore_Thread *thread)
break; break;
} }
eio_file_container_set(&async->ls.common, NULL);
eina_iterator_free(ls); eina_iterator_free(ls);
} }
@ -172,6 +176,8 @@ _eio_file_eina_ls_heavy(Ecore_Thread *thread, Eio_File_Direct_Ls *async, Eina_It
return ; return ;
} }
eio_file_container_set(&async->ls.common, eina_iterator_container_get(ls));
EINA_ITERATOR_FOREACH(ls, info) EINA_ITERATOR_FOREACH(ls, info)
{ {
Eina_Bool filter = EINA_TRUE; Eina_Bool filter = EINA_TRUE;
@ -197,6 +203,8 @@ _eio_file_eina_ls_heavy(Ecore_Thread *thread, Eio_File_Direct_Ls *async, Eina_It
break; break;
} }
eio_file_container_set(&async->ls.common, NULL);
eina_iterator_free(ls); eina_iterator_free(ls);
} }
@ -826,6 +834,22 @@ eio_file_cancel(Eio_File *ls)
return ecore_thread_cancel(ls->thread); return ecore_thread_cancel(ls->thread);
} }
/**
* @brief Return the container during EIO operation
* @param ls The asynchronous IO operation to retrieve container from.
* @return NULL if not available, a DIRP if it is.
*
* This is only available and make sense in the thread callback, not in
* the mainloop.
*/
EAPI void *
eio_file_container_get(Eio_File *ls)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(ls, EINA_FALSE);
return ls->container;
}
/** /**
* @brief Copy a file asynchronously * @brief Copy a file asynchronously
* @param source Should be the name of the file to copy the data from. * @param source Should be the name of the file to copy the data from.

View File

@ -67,6 +67,7 @@ struct _Eio_File
{ {
Ecore_Thread *thread; Ecore_Thread *thread;
const void *data; const void *data;
void *container;
int error; int error;
@ -192,6 +193,8 @@ Eina_Bool eio_long_file_set(Eio_File *common,
Ecore_Thread_Cb end_cb, Ecore_Thread_Cb end_cb,
Ecore_Thread_Cb cancel_cb); Ecore_Thread_Cb cancel_cb);
void eio_file_container_set(Eio_File *common, void *container);
void eio_file_error(Eio_File *common); void eio_file_error(Eio_File *common);
void eio_file_thread_error(Eio_File *common, Ecore_Thread *thread); void eio_file_thread_error(Eio_File *common, Ecore_Thread *thread);

View File

@ -275,6 +275,7 @@ eio_long_file_set(Eio_File *common,
common->data = data; common->data = data;
common->error = 0; common->error = 0;
common->thread = NULL; common->thread = NULL;
common->container = NULL;
/* Be aware that ecore_thread_feedback_run could call cancel_cb if something goes wrong. /* Be aware that ecore_thread_feedback_run could call cancel_cb if something goes wrong.
This means that common would be destroyed if thread == NULL. This means that common would be destroyed if thread == NULL.
@ -305,6 +306,7 @@ eio_file_set(Eio_File *common,
common->data = data; common->data = data;
common->error = 0; common->error = 0;
common->thread = NULL; common->thread = NULL;
common->container = NULL;
/* Be aware that ecore_thread_run could call cancel_cb if something goes wrong. /* Be aware that ecore_thread_run could call cancel_cb if something goes wrong.
This means that common would be destroyed if thread == NULL. This means that common would be destroyed if thread == NULL.
@ -315,6 +317,12 @@ eio_file_set(Eio_File *common,
return !!thread; return !!thread;
} }
void
eio_file_container_set(Eio_File *common, void *container)
{
common->container = container;
}
/** /**
* @endcond * @endcond
*/ */