\chapter{eio\+\_\+monitor\+\_\+add() tutorial}
\hypertarget{tutorial_monitor_add}{}\label{tutorial_monitor_add}\index{eio\_monitor\_add() tutorial@{eio\_monitor\_add() tutorial}}
To use \doxylink{group__Eio__Monitor_ga88eefb705bf6512400a890ceafde57f1}{eio\+\_\+monitor\+\_\+add()}, you have to define callbacks for events declared by eio. Available events are \+:
\begin{DoxyItemize}
\item EIO\+\_\+\+MONITOR\+\_\+\+FILE\+\_\+\+CREATED
\item EIO\+\_\+\+MONITOR\+\_\+\+FILE\+\_\+\+DELETED
\item EIO\+\_\+\+MONITOR\+\_\+\+FILE\+\_\+\+MODIFIED
\item EIO\+\_\+\+MONITOR\+\_\+\+FILE\+\_\+\+CLOSED
\item EIO\+\_\+\+MONITOR\+\_\+\+DIRECTORY\+\_\+\+CREATED
\item EIO\+\_\+\+MONITOR\+\_\+\+DIRECTORY\+\_\+\+DELETED
\item EIO\+\_\+\+MONITOR\+\_\+\+DIRECTORY\+\_\+\+CLOSED
\item EIO\+\_\+\+MONITOR\+\_\+\+SELF\+\_\+\+RENAME
\item EIO\+\_\+\+MONITOR\+\_\+\+SELF\+\_\+\+DELETED
\end{DoxyItemize}

As nothing is worth an example, here it is \+: 
\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <\mbox{\hyperlink{Eina_8h}{Eina.h}}>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <Ecore.h>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <Eio.h>}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keywordtype}{void}\ file\_modified(\textcolor{keywordtype}{void}\ *data,\ \textcolor{keywordtype}{int}\ type,\ \textcolor{keywordtype}{void}\ *event)}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *filename\ =\ (\textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *)data;}
\DoxyCodeLine{\ \ \ printf(\textcolor{stringliteral}{"{}file\ \%s\ "{}},\ filename);}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{if}(\ type\ ==\ \mbox{\hyperlink{group__Eio__Monitor_ga32f7035a95562b310b47f18c64d41703}{EIO\_MONITOR\_FILE\_MODIFIED}}\ )}
\DoxyCodeLine{\ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}is\ being\ modified"{}});}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}(\ type\ ==\ \mbox{\hyperlink{group__Eio__Monitor_ga5120e3f3257f74bf664eaf91af85589f}{EIO\_MONITOR\_FILE\_CLOSED}}\ )}
\DoxyCodeLine{\ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}is\ no\ longer\ being\ modified"{}});}
\DoxyCodeLine{\ \ \ \textcolor{keywordflow}{else}\ printf(\textcolor{stringliteral}{"{}got\ unexpected\ changes"{}});}
\DoxyCodeLine{\ \ \ printf(\textcolor{stringliteral}{"{}\(\backslash\)n"{}});}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keywordtype}{int}\ main(\textcolor{keywordtype}{int}\ argc,\ \textcolor{keywordtype}{char}\ **argv)\ \{}
\DoxyCodeLine{\ \ \ Eio\_Monitor\ *monitor\ \ =\ NULL,}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *monitor2\ =\ NULL;}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Eio__Helper_ga557c198fc1a90518d7872b77843fa029}{eio\_init}}();}
\DoxyCodeLine{\ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{char}\ *filename\ =\ \mbox{\hyperlink{group__Eina__Stringshare__Group_ga4e3ce40744291c1fb8574e26883c0bf2}{eina\_stringshare\_add}}(\textcolor{stringliteral}{"{}/tmp/eio\_notify\_testfile"{}});}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ monitor\ \ =\ \mbox{\hyperlink{group__Eio__Monitor_ga88eefb705bf6512400a890ceafde57f1}{eio\_monitor\_add}}(filename);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Ecore__Event__Group_ga886c90c3f917f87b3b4c931adcbc41c5}{ecore\_event\_handler\_add}}(\mbox{\hyperlink{group__Eio__Monitor_ga32f7035a95562b310b47f18c64d41703}{EIO\_MONITOR\_FILE\_MODIFIED}},\ (\mbox{\hyperlink{group__Ecore__Event__Group_ga64b4df04cbafda481593d0bc29617c6d}{Ecore\_Event\_Handler\_Cb}})file\_modified,\ filename);}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Ecore__Event__Group_ga886c90c3f917f87b3b4c931adcbc41c5}{ecore\_event\_handler\_add}}(\mbox{\hyperlink{group__Eio__Monitor_ga5120e3f3257f74bf664eaf91af85589f}{EIO\_MONITOR\_FILE\_CLOSED}},\ (\mbox{\hyperlink{group__Ecore__Event__Group_ga64b4df04cbafda481593d0bc29617c6d}{Ecore\_Event\_Handler\_Cb}})file\_modified,\ filename);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Ecore__Main__Loop__Group_gaf103b9f668bb3e4fed12e52c6180132d}{ecore\_main\_loop\_begin}}();}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Eio__Helper_ga7c3ad77c3f9a0346aab50f474af54b6c}{eio\_shutdown}}();}
\DoxyCodeLine{\ \ \ \mbox{\hyperlink{group__Eina__Stringshare__Group_ga5538b4a134987b8a01744fad1a845ba4}{eina\_stringshare\_del}}(filename);}
\DoxyCodeLine{\}}

\end{DoxyCode}
 Build the example doing \+: \begin{DoxyVerb}gcc -o tutorial_monitor_add tutorial_monitor_add.c `pkg-config --libs --cflags eio ecore ecore-file eina`
* then create the file /tmp/eio_notify_testfile :
* touch /tmp/eio_notify_testfile
* and launch tutorial_monitor_add, and in another terminal, write into /tmp/eio_notify_testfile, doing for example :
* echo "test" >> /tmp/eio_notify_testfile
* \end{DoxyVerb}
 