

For brevity, variable declarations and initialization are omitted from this page, however the full source code can be seen \mbox{\hyperlink{eina_file_example_01}{here}}.

Here we have a simple callback to print the name of a file and the path that contains it\+: 
\begin{DoxyCodeInclude}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_print\_cb(\textcolor{keyword}{const} \textcolor{keywordtype}{char} *name, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *path, \textcolor{keywordtype}{void} *data \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})
\{
   printf(\textcolor{stringliteral}{"file %s in %s\(\backslash\)n"}, name, path);
\}

\end{DoxyCodeInclude}


We can use this callback in the following call\+: 
\begin{DoxyCodeInclude}
   \mbox{\hyperlink{group__Eina__File__Group_ga186dc8dd1a166a8972189f78bbee15ea}{eina\_file\_dir\_list}}(\textcolor{stringliteral}{"/home/"}, \mbox{\hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\_FALSE}}, \_print\_cb, NULL);

\end{DoxyCodeInclude}


The above is a way to print the files in a directory, but it is not the only one\+: 
\begin{DoxyCodeInclude}

   it = \mbox{\hyperlink{group__Eina__File__Group_ga8c4fabb379b865a4ec134a5c4436be2a}{eina\_file\_ls}}(\textcolor{stringliteral}{"/home/"});
   \mbox{\hyperlink{group__Eina__Iterator__Group_gac7314580e18868ef229f5d2814562794}{EINA\_ITERATOR\_FOREACH}}(it, f\_name)
     \{
        printf(\textcolor{stringliteral}{"%s\(\backslash\)n"}, f\_name);
        \mbox{\hyperlink{group__Eina__Stringshare__Group_ga495411b0bc85b9c0d59ec7255a025260}{eina\_stringshare\_del}}(f\_name);
     \}
   \mbox{\hyperlink{group__Eina__Iterator__Group_gaf9261991a4b05dc63e3401278a3281f8}{eina\_iterator\_free}}(it);

\end{DoxyCodeInclude}


And now two ways to get more information than just file names\+: 
\begin{DoxyCodeInclude}

   it = \mbox{\hyperlink{group__Eina__File__Group_ga21d5e94767ae9932751649ce09a2f98f}{eina\_file\_stat\_ls}}(\textcolor{stringliteral}{"/home/"});
   \mbox{\hyperlink{group__Eina__Iterator__Group_gac7314580e18868ef229f5d2814562794}{EINA\_ITERATOR\_FOREACH}}(it, f\_info)
     printf(\textcolor{stringliteral}{"%s if of type %d\(\backslash\)n"}, f\_info->path, f\_info->type);
   \mbox{\hyperlink{group__Eina__Iterator__Group_gaf9261991a4b05dc63e3401278a3281f8}{eina\_iterator\_free}}(it);

   it = \mbox{\hyperlink{group__Eina__File__Group_ga90d5372f6c6ef085760e26cb8c4993c8}{eina\_file\_direct\_ls}}(\textcolor{stringliteral}{"/home/"});
   \mbox{\hyperlink{group__Eina__Iterator__Group_gac7314580e18868ef229f5d2814562794}{EINA\_ITERATOR\_FOREACH}}(it, f\_info)
     printf(\textcolor{stringliteral}{"%s if of type %d\(\backslash\)n"}, f\_info->path, f\_info->type);
   \mbox{\hyperlink{group__Eina__Iterator__Group_gaf9261991a4b05dc63e3401278a3281f8}{eina\_iterator\_free}}(it);

\end{DoxyCodeInclude}


The above mentioned ways of getting files on a list may produce the same output, but they have an important difference, \mbox{\hyperlink{group__Eina__File__Group_ga90d5372f6c6ef085760e26cb8c4993c8}{eina\+\_\+file\+\_\+direct\+\_\+ls()}} does {\bfseries not} call stat, this means that on some systems it might not have file type information. On the other hand, it might be faster than \mbox{\hyperlink{group__Eina__File__Group_ga21d5e94767ae9932751649ce09a2f98f}{eina\+\_\+file\+\_\+stat\+\_\+ls()}}. 