\chapter{eio\+\_\+file\+\_\+ls() tutorial}
\hypertarget{tutorial_file_ls}{}\label{tutorial_file_ls}\index{eio\_file\_ls() tutorial@{eio\_file\_ls() tutorial}}
To use \doxylink{group__Eio__List_ga4f2b3506617c59ed5df247d26b6b628f}{eio\+\_\+file\+\_\+ls()}, you just need to define four callbacks\+:

\begin{DoxyItemize}
\item The filter callback, which allows a file to be seen (or not) by the main loop handler. This callback runs in a separate thread. \item The main callback, which receive in the main loop all the file that are allowed by the filter. If you are updating a user interface it makes sense to delay the insertion a little, so you get a chance to update the canvas for a bunch of files instead of one by one. \item The end callback, which is called in the main loop when the content of the directory has been correctly scanned and all the file notified to the main loop. \item The error callback, which is called if an error occurred or if the listing was cancelled during its run. You can then retrieve the error type as an errno error.\end{DoxyItemize}
Here is a simple example\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <Ecore.h>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <Eio.h>}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}}}
\DoxyCodeLine{\_test\_filter\_cb(\textcolor{keywordtype}{void}\ *data,\ Eio\_File\ *handler,\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *file)}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ fprintf(stderr,\ \textcolor{stringliteral}{"{}ACCEPTING:\ \%s\(\backslash\)n"{}},\ file);}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{return}\ \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}};}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_test\_main\_cb(\textcolor{keywordtype}{void}\ *data,\ Eio\_File\ *handler,\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *file)}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ fprintf(stderr,\ \textcolor{stringliteral}{"{}PROCESS:\ \%s\(\backslash\)n"{}},\ file);}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_test\_done\_cb(\textcolor{keywordtype}{void}\ *data,\ Eio\_File\ *handler)}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ printf(\textcolor{stringliteral}{"{}ls\ done\(\backslash\)n"{}});}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Ecore__Main__Loop__Group_ga95cf8e97dff0716433c2c5474d606a98}{ecore\_main\_loop\_quit}}();}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static}\ \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_test\_error\_cb(\textcolor{keywordtype}{void}\ *data,\ Eio\_File\ *handler,\ \textcolor{keywordtype}{int}\ error)}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ fprintf(stderr,\ \textcolor{stringliteral}{"{}error:\ [\%s]\(\backslash\)n"{}},\ strerror(error));}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Ecore__Main__Loop__Group_ga95cf8e97dff0716433c2c5474d606a98}{ecore\_main\_loop\_quit}}();}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keywordtype}{int}}
\DoxyCodeLine{main(\textcolor{keywordtype}{int}\ argc,\ \textcolor{keywordtype}{char}\ **argv)}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ Eio\_File\ *cp;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}\ (argc\ !=\ 2)}
\DoxyCodeLine{\ \ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ fprintf(stderr,\ \textcolor{stringliteral}{"{}eio\_ls\ directory\(\backslash\)n"{}});}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ -\/1;}
\DoxyCodeLine{\ \ \ \ \ \}}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Ecore__Init__Group_ga77757609684a2c922dc5ec398274751b}{ecore\_init}}();}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Eio__Helper_ga557c198fc1a90518d7872b77843fa029}{eio\_init}}();}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ cp\ =\ \mbox{\hyperlink{group__Eio__List_ga4f2b3506617c59ed5df247d26b6b628f}{eio\_file\_ls}}(argv[1],}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \_test\_filter\_cb,}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \_test\_main\_cb,}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \_test\_done\_cb,}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \_test\_error\_cb,}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ NULL);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Ecore__Main__Loop__Group_gaf103b9f668bb3e4fed12e52c6180132d}{ecore\_main\_loop\_begin}}();}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Eio__Helper_ga7c3ad77c3f9a0346aab50f474af54b6c}{eio\_shutdown}}();}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Ecore__Init__Group_ga768298b932f18d7e7593a447493e5cde}{ecore\_shutdown}}();}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{return}\ 0;}
\DoxyCodeLine{\}}

\end{DoxyCode}
 