eina_file_example_01

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

eina_file_example_01
//Compile with:
//gcc -g eina_file_01.c -o eina_file_01 `pkg-config --cflags --libs eina`
#include <stdio.h>
#include <Eina.h>
static void
_print_cb(const char *name, const char *path, void *data EINA_UNUSED)
{
printf("file %s in %s\n", name, path);
}
int
main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
{
Eina_Iterator *it;
const char *f_name;
const Eina_File_Direct_Info *f_info;
eina_init();
eina_file_dir_list("/home/", EINA_FALSE, _print_cb, NULL);
it = eina_file_ls("/home/");
EINA_ITERATOR_FOREACH(it, f_name)
{
printf("%s\n", f_name);
eina_stringshare_del(f_name);
}
eina_iterator_free(it);
it = eina_file_stat_ls("/home/");
EINA_ITERATOR_FOREACH(it, f_info)
printf("%s if of type %d\n", f_info->path, f_info->type);
eina_iterator_free(it);
it = eina_file_direct_ls("/home/");
EINA_ITERATOR_FOREACH(it, f_info)
printf("%s if of type %d\n", f_info->path, f_info->type);
eina_iterator_free(it);
eina_shutdown();
return 0;
}
Eina.h
Eina Utility library.
eina_file_stat_ls
EINA_API Eina_Iterator * eina_file_stat_ls(const char *dir)
Gets an iterator to list the content of a directory, with direct information.
Definition: eina_file_posix.c:739
eina_file_direct_ls
EINA_API Eina_Iterator * eina_file_direct_ls(const char *dir)
Gets an iterator to list the content of a directory, with direct information.
Definition: eina_file_posix.c:679
eina_file_ls
EINA_API Eina_Iterator * eina_file_ls(const char *dir)
Gets an iterator to list the content of a directory.
Definition: eina_file_posix.c:631
eina_file_dir_list
EINA_API Eina_Bool eina_file_dir_list(const char *dir, Eina_Bool recursive, Eina_File_Dir_List_Cb cb, void *data)
Lists all the files on the directory by calling the function for every file found.
Definition: eina_file_posix.c:566
eina_iterator_free
EINA_API void eina_iterator_free(Eina_Iterator *iterator)
Frees an iterator.
Definition: eina_iterator.c:98
EINA_ITERATOR_FOREACH
#define EINA_ITERATOR_FOREACH(itr, data)
Definition for the macro to iterate over all elements easily.
Definition: eina_iterator.h:448
eina_shutdown
EINA_API int eina_shutdown(void)
Shuts down the Eina library.
Definition: eina_main.c:379
eina_init
EINA_API int eina_init(void)
Initializes the Eina library.
Definition: eina_main.c:291
eina_stringshare_del
EINA_API void eina_stringshare_del(Eina_Stringshare *str)
Notes that the given string has lost an instance.
Definition: eina_stringshare.c:533
EINA_FALSE
#define EINA_FALSE
boolean value FALSE (numerical value 0)
Definition: eina_types.h:533
EINA_UNUSED
#define EINA_UNUSED
Used to indicate that a function parameter is purposely unused.
Definition: eina_types.h:339
_Eina_File_Direct_Info
The structure to store information of a path.
Definition: eina_file.h:193
_Eina_File_Direct_Info::type
Eina_File_Type type
File type.
Definition: eina_file.h:197
_Eina_File_Direct_Info::path
char path[EINA_PATH_MAX]
The path.
Definition: eina_file.h:198
_Eina_Iterator
structure of an iterator
Definition: eina_iterator.h:159