- Main Page
- Related Pages
- Modules
- Data Structures
- Files
- Examples

Eio

Date
  2012 (created)

# Table of Contents

- Introduction
- How to compile
- Next Steps
- Introductory Example

# Introduction

The Eio library is a library that implements an API for asynchronous input/output operation. Most operation are done in a separated thread to prevent lock. See Eio_Group. Some helper to work on data received in Eio callback are also provided see Eio Reference helper API. It is also possible to work asynchronously on Eina_File with Manipulate an Eina_File asynchronously or on Eet_File with Eio asynchronous API for Eet file.. It come with way to manipulate eXtended attribute assynchronously with Eio manipulation of eXtended attribute..

This library is cross-platform and can be compiled and used on Linux, BSD, Opensolaris and Windows (XP and CE). It is heavily based on Ecore main loop.

# How to compile

Eio is a library your application links to. The procedure for this is very simple. You simply have to compile your application with the appropriate compiler flags that the `pkg-config` script outputs. For example:

Compiling C or C++ files into object files:

    gcc -c -o main.o main.c `pkg-config --cflags eio`

Linking object files into a binary executable:

    gcc -o my_application main.o `pkg-config --libs eio`

See pkgconfig

# Next Steps

After you understood what Eio is and installed it in your system you should proceed understanding the programming interface.

Recommended reading:

- Eio Reference helper API for common functions and library initialization.
- Manipulate an Eina_File asynchronously to manipulate files asynchronously (mmap).
- Eio manipulation of eXtended attribute. to access file extended attributes (xattr).
- Eio file and directory monitoring API to monitor for file changes (inotify).
- Eio asynchronous API for Eet file. to access Eet files asynchronously.

# Introductory Example

//Compile with:
//gcc -o eio_file_ls eio_file_ls.c `pkg-config --cflags --libs ecore eio`
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <Eio.h>
#include <Ecore.h>
static Eina_Bool
_filter_cb(void *data, Eio_File *handler, const char *file)
{
char *last_slash = strrchr(file, '/');
//Check if it is a hidden file
if (last_slash != NULL && strlen(last_slash) > 1 && last_slash[1] == '.')
return EINA_FALSE;
return EINA_TRUE;
}
static void
_main_cb(void *data, Eio_File *handler, const char *file)
{
int *number_of_listed_files = (int *)data;
fprintf(stdout, "Processing file:%s\n", file);
(*number_of_listed_files)++;
}
static void
_done_cb(void *data, Eio_File *handler)
{
int *number_of_listed_files = (int *)data;
fprintf(stdout, "Number of listed files:%d\n" \
"ls operation is done, quitting.\n", *number_of_listed_files);
ecore_main_loop_quit();
}
static void
_error_cb(void *data, Eio_File *handler, int error)
{
fprintf(stderr, "Something wrong has happend:%s\n", strerror(error));
ecore_main_loop_quit();
}
int
main(int argc, char **argv)
{
int number_of_listed_files = 0;
ecore_init();
eio_init();
if (argc < 2)
{
fprintf(stderr, "You must pass a path to execute the command.\n");
return -1;
}
eio_file_ls(argv[1], _filter_cb, _main_cb, _done_cb, _error_cb,
&number_of_listed_files);
ecore_main_loop_begin();
eio_shutdown();
ecore_shutdown();
return 0;
}

More examples can be found at Eio Examples.