\hypertarget{eio_file_ls_8c-example}{}\section{eio\+\_\+file\+\_\+ls.\+c}

\begin{DoxyCodeInclude}
\textcolor{comment}{//Compile with:}
\textcolor{comment}{//gcc -o eio\_file\_ls eio\_file\_ls.c `pkg-config --cflags --libs ecore eio`}

\textcolor{preprocessor}{#include <stdlib.h>}
\textcolor{preprocessor}{#include <stdio.h>}
\textcolor{preprocessor}{#include <string.h>}
\textcolor{preprocessor}{#include <Eio.h>}
\textcolor{preprocessor}{#include <Ecore.h>}

\textcolor{keyword}{static} \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}}
\_filter\_cb(\textcolor{keywordtype}{void} *data \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}}, \mbox{\hyperlink{group__Eio_ga1145f009745ecb4d9f6a01a9bc5a9ac0}{Eio\_File}} *handler 
      \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}}, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *file)
\{
   \textcolor{keywordtype}{char} *last\_slash = strrchr(file, \textcolor{charliteral}{'/'});

   \textcolor{comment}{//Check if it is a hidden file}
   \textcolor{keywordflow}{if} (last\_slash != NULL && strlen(last\_slash) > 1 && last\_slash[1] == \textcolor{charliteral}{'.'})
     \textcolor{keywordflow}{return} \mbox{\hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\_FALSE}};

   \textcolor{keywordflow}{return} \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}};
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_main\_cb(\textcolor{keywordtype}{void} *data, \mbox{\hyperlink{group__Eio_ga1145f009745ecb4d9f6a01a9bc5a9ac0}{Eio\_File}} *handler \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}}, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *file)
\{
   \textcolor{keywordtype}{int} *number\_of\_listed\_files = (\textcolor{keywordtype}{int} *)data;

   printf(\textcolor{stringliteral}{"Processing file:%s\(\backslash\)n"}, file);

   (*number\_of\_listed\_files)++;
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_done\_cb(\textcolor{keywordtype}{void} *data, \mbox{\hyperlink{group__Eio_ga1145f009745ecb4d9f6a01a9bc5a9ac0}{Eio\_File}} *handler \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})
\{
   \textcolor{keywordtype}{int} *number\_of\_listed\_files = (\textcolor{keywordtype}{int} *)data;

   printf(\textcolor{stringliteral}{"Number of listed files:%d\(\backslash\)n"} \(\backslash\)
           \textcolor{stringliteral}{"ls operation is done, quitting.\(\backslash\)n"}, *number\_of\_listed\_files);

   \mbox{\hyperlink{group__Ecore__Main__Loop__Group_ga95cf8e97dff0716433c2c5474d606a98}{ecore\_main\_loop\_quit}}();
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_error\_cb(\textcolor{keywordtype}{void} *data \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}}, \mbox{\hyperlink{group__Eio_ga1145f009745ecb4d9f6a01a9bc5a9ac0}{Eio\_File}} *handler 
      \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}}, \textcolor{keywordtype}{int} error)
\{
   fprintf(stderr, \textcolor{stringliteral}{"Something has gone wrong:%s\(\backslash\)n"}, strerror(error));
   \mbox{\hyperlink{group__Ecore__Main__Loop__Group_ga95cf8e97dff0716433c2c5474d606a98}{ecore\_main\_loop\_quit}}();
\}

\textcolor{keywordtype}{int}
main(\textcolor{keywordtype}{int} argc, \textcolor{keywordtype}{char} **argv)
\{
   \textcolor{keywordtype}{int} number\_of\_listed\_files = 0;

   \mbox{\hyperlink{group__Ecore__Init__Group_ga77757609684a2c922dc5ec398274751b}{ecore\_init}}();
   \mbox{\hyperlink{group__Eio__Helper_ga89ffd478ac602179bf7877ed6adc90a9}{eio\_init}}();

   \textcolor{keywordflow}{if} (argc < 2)
     \{
        fprintf(stderr, \textcolor{stringliteral}{"You must pass a path to execute the command.\(\backslash\)n"});
        \textcolor{keywordflow}{return}  -1;
     \}

   \mbox{\hyperlink{group__Eio__List_gaa1f1c391838be672433b3d1de70139cd}{eio\_file\_ls}}(argv[1], \_filter\_cb, \_main\_cb, \_done\_cb, \_error\_cb,
               &number\_of\_listed\_files);

   \mbox{\hyperlink{group__Ecore__Main__Loop__Group_gaf103b9f668bb3e4fed12e52c6180132d}{ecore\_main\_loop\_begin}}();

   \mbox{\hyperlink{group__Eio__Helper_ga8eea29cef62953a2916aecb08b222d66}{eio\_shutdown}}();
   \mbox{\hyperlink{group__Ecore__Init__Group_ga768298b932f18d7e7593a447493e5cde}{ecore\_shutdown}}();

   \textcolor{keywordflow}{return} 0;
\}
\end{DoxyCodeInclude}
 