forked from enlightenment/efl
eio: add API for eina_file_open and like.
tweet: now Eio can help you load your file assynchronously ! SVN revision: 66397
This commit is contained in:
parent
4d01164eb6
commit
dbccbce821
|
@ -123,6 +123,10 @@ typedef void (*Eio_Main_Direct_Cb)(void *data, Eio_File *handler, const Eina_Fil
|
|||
typedef void (*Eio_Stat_Cb)(void *data, Eio_File *handler, const struct stat *stat);
|
||||
typedef void (*Eio_Progress_Cb)(void *data, Eio_File *handler, const Eio_Progress *info);
|
||||
|
||||
typedef void (*Eio_Open_Cb)(void *data, Eio_File *handler, Eina_File *file);
|
||||
typedef Eina_Bool (*Eio_Filter_Map_Cb)(void *data, Eio_File *handler, void *map);
|
||||
typedef void (*Eio_Map_Cb)(void *data, Eio_File *handler, void *map);
|
||||
|
||||
typedef void (*Eio_Done_Data_Cb)(void *data, Eio_File *handler, const char *xattr_data, unsigned int xattr_size);
|
||||
typedef void (*Eio_Done_String_Cb)(void *data, Eio_File *handler, const char *xattr_string);
|
||||
typedef void (*Eio_Done_Double_Cb)(void *data, Eio_File *handler, double xattr_double);
|
||||
|
@ -678,6 +682,86 @@ static inline Eina_Bool eio_file_is_lnk(const struct stat *stat);
|
|||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup Eio_Map Manipulate an Eina_File assynchronously
|
||||
*
|
||||
* @brief This function help manipulating file assynchronously.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Assynchronously open a file.
|
||||
* @param name The file to open.
|
||||
* @param shared If it's an shm file.
|
||||
* @param open_cb Callback called in the main loop when the file has been successfully opened.
|
||||
* @param error_cb Callback called in the main loop when the file couldn't be opened.
|
||||
* @param data Private data given to each callback.
|
||||
* @return NULL in case of a failure.
|
||||
*/
|
||||
EAPI Eio_File *eio_file_open(const char *name, Eina_Bool shared,
|
||||
Eio_Open_Cb open_cb,
|
||||
Eio_Error_Cb error_cb,
|
||||
const void *data);
|
||||
|
||||
/**
|
||||
* @brief Assynchronously close a file.
|
||||
* @param f The file to close.
|
||||
* @param done_cb Callback called in the main loop when the file has been successfully closed.
|
||||
* @param error_cb Callback called in the main loop when the file couldn't be closed.
|
||||
* @param data Private data given to each callback.
|
||||
* @return NULL in case of a failure.
|
||||
*/
|
||||
EAPI Eio_File *eio_file_close(Eina_File *f,
|
||||
Eio_Done_Cb done_cb,
|
||||
Eio_Error_Cb error_cb,
|
||||
const void *data);
|
||||
|
||||
/**
|
||||
* @brief Assynchronously map a file in memory.
|
||||
* @param f The file to map.
|
||||
* @param rule The rule to apply to the map.
|
||||
* @param filter_cb Callback called in the thread to validate the content of the map.
|
||||
* @param map_cb Callback called in the main loop when the file has been successfully mapped.
|
||||
* @param error_cb Callback called in the main loop when the file can't be mapped.
|
||||
* @param data Private data given to each callback.
|
||||
* @return NULL in case of a failure.
|
||||
*
|
||||
* The container of the Eio_File is the Eina_File.
|
||||
*/
|
||||
EAPI Eio_File *eio_file_map_all(Eina_File *f,
|
||||
Eina_File_Populate rule,
|
||||
Eio_Filter_Map_Cb filter_cb,
|
||||
Eio_Map_Cb map_cb,
|
||||
Eio_Error_Cb error_cb,
|
||||
const void *data);
|
||||
|
||||
/**
|
||||
* @brief Assynchronously map a part of a file in memory.
|
||||
* @param f The file to map.
|
||||
* @param rule The rule to apply to the map.
|
||||
* @param offset The offset inside the file
|
||||
* @param length The length of the memory to map
|
||||
* @param filter_cb Callback called in the thread to validate the content of the map.
|
||||
* @param map_cb Callback called in the main loop when the file has been successfully mapped.
|
||||
* @param error_cb Callback called in the main loop when the file can't be mapped.
|
||||
* @param data Private data given to each callback.
|
||||
* @return NULL in case of a failure.
|
||||
*
|
||||
* The container of the Eio_File is the Eina_File.
|
||||
*/
|
||||
EAPI Eio_File *eio_file_map_new(Eina_File *f,
|
||||
Eina_File_Populate rule,
|
||||
unsigned long int offset,
|
||||
unsigned long int length,
|
||||
Eio_Filter_Map_Cb filter_cb,
|
||||
Eio_Map_Cb map_cb,
|
||||
Eio_Error_Cb error_cb,
|
||||
const void *data);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup Eio_Monitor Eio file and directory monitoring API
|
||||
*
|
||||
|
|
|
@ -16,6 +16,7 @@ eio_single.c \
|
|||
eio_dir.c \
|
||||
eio_monitor.c \
|
||||
eio_poll.c \
|
||||
eio_map.c \
|
||||
eio_xattr.c
|
||||
|
||||
if EIO_HAVE_INOTIFY
|
||||
|
|
|
@ -51,6 +51,8 @@
|
|||
|
||||
#define EIO_PACKED_TIME 0.003
|
||||
|
||||
typedef struct _Eio_File_Map Eio_File_Map;
|
||||
typedef struct _Eio_File_Map_Rule Eio_File_Map_Rule;
|
||||
typedef struct _Eio_File_Ls Eio_File_Ls;
|
||||
typedef struct _Eio_File_Direct_Ls Eio_File_Direct_Ls;
|
||||
typedef struct _Eio_File_Char_Ls Eio_File_Char_Ls;
|
||||
|
@ -109,6 +111,30 @@ struct _Eio_File
|
|||
} worker, main;
|
||||
};
|
||||
|
||||
struct _Eio_File_Map
|
||||
{
|
||||
Eio_File common;
|
||||
|
||||
Eio_Open_Cb open_cb;
|
||||
const char *name;
|
||||
Eina_Bool shared;
|
||||
|
||||
Eina_File *result;
|
||||
};
|
||||
|
||||
struct _Eio_File_Map_Rule
|
||||
{
|
||||
Eio_File common;
|
||||
Eio_Filter_Map_Cb filter_cb;
|
||||
Eio_Map_Cb map_cb;
|
||||
Eina_File_Populate rule;
|
||||
|
||||
unsigned long int offset;
|
||||
unsigned long int length;
|
||||
|
||||
void *result;
|
||||
};
|
||||
|
||||
struct _Eio_File_Ls
|
||||
{
|
||||
Eio_File common;
|
||||
|
|
Loading…
Reference in New Issue