File
[Tools]
Functions to traverse directories and split paths.
More...Data Structures | |
struct | _Eina_File_Direct_Info |
A structure to store informations of a path. More... | |
Defines | |
#define | EINA_FILE_DIR_LIST_CB(function) ((Eina_File_Dir_List_Cb)function) |
cast to an Eina_File_Dir_List_Cb. | |
Typedefs | |
typedef struct _Eina_File_Direct_Info | Eina_File_Direct_Info |
A typedef to _Eina_File_Direct_Info. | |
typedef void(* | Eina_File_Dir_List_Cb )(const char *name, const char *path, void *data) |
Type for a callback to be called when iterating over the files of a directory. | |
Functions | |
EAPI Eina_Bool | eina_file_dir_list (const char *dir, Eina_Bool recursive, Eina_File_Dir_List_Cb cb, void *data) |
List all files on the directory calling the function for every file found. | |
EAPI Eina_Bool EAPI Eina_Array * | eina_file_split (char *path) |
Split a path according to the delimiter of the filesystem. | |
EAPI Eina_Iterator * | eina_file_ls (const char *dir) |
Get an iterator to list the content of a directory. | |
EAPI Eina_Iterator * | eina_file_direct_ls (const char *dir) |
Get an iterator to list the content of a directory, with direct information. |
Detailed Description
Functions to traverse directories and split paths.
- eina_file_dir_list() list the content of a directory, recusrsively or not, and can call a callback function for eachfound file.
- eina_file_split() split a path into all the subdirectories that compose it, according to the separator of the file system.
Define Documentation
#define EINA_FILE_DIR_LIST_CB | ( | function | ) | ((Eina_File_Dir_List_Cb)function) |
cast to an Eina_File_Dir_List_Cb.
- Parameters:
-
function The function to cast.
function
to Eina_File_Dir_List_Cb.
Function Documentation
EAPI Eina_Bool eina_file_dir_list | ( | const char * | dir, | |
Eina_Bool | recursive, | |||
Eina_File_Dir_List_Cb | cb, | |||
void * | data | |||
) |
List all files on the directory calling the function for every file found.
- Parameters:
-
dir The directory name. recursive Iterate recursively in the directory. cb The callback to be called. data The data to pass to the callback.
- Returns:
- EINA_TRUE on success, EINA_FALSE otherwise.
dir
. To list also all the sub directoris recursively, recursive
must be set to EINA_TRUE, otherwise it must be set to EINA_FALSE. For each found file, cb
is called and data
is passed to it.
If cb
or dir
are NULL
, or if dir
is a string of size 0, or if dir
can not be opened, this function returns EINA_FALSE immediately. otherwise, it returns EINA_TRUE.
EAPI Eina_Array * eina_file_split | ( | char * | path | ) |
Split a path according to the delimiter of the filesystem.
- Parameters:
-
path The path to split.
- Returns:
- An array of the parts of the path to split.
path
according to the delimiter of the used filesystem. If path
is NULL
or if the array can not be created, NULL
is returned, otherwise, an array with the different parts of path
is returned.
EAPI Eina_Iterator * eina_file_ls | ( | const char * | dir | ) |
Get an iterator to list the content of a directory.
Iterators are cheap to be created and allow interruption at any iteration. At each iteration, only the next directory entry is read from the filesystem with readdir().
The iterator will handle the user a stringshared value with the full path. One must call eina_stringshare_del() on it after usage to not leak!
The eina_file_direct_ls() function will provide a possibly faster alternative if you need to filter the results somehow, like checking extension.
The iterator will walk over '.' and '..' without returning them.
- Parameters:
-
dir The name of the directory to list
- Returns:
- Return an Eina_Iterator that will walk over the files and directory in the pointed directory. On failure it will return NULL. The iterator emits stringshared value with the full path and must be freed with eina_stringshare_del().
- See also:
- eina_file_direct_ls()
EAPI Eina_Iterator * eina_file_direct_ls | ( | const char * | dir | ) |
Get an iterator to list the content of a directory, with direct information.
Iterators are cheap to be created and allow interruption at any iteration. At each iteration, only the next directory entry is read from the filesystem with readdir().
The iterator returns the direct pointer to couple of useful information in Eina_File_Direct_Info and that pointer should not be modified anyhow!
The iterator will walk over '.' and '..' without returning them.
- Parameters:
-
dir The name of the directory to list
- Returns:
- Return an Eina_Iterator that will walk over the files and directory in the pointed directory. On failure it will return NULL. The iterator emits Eina_File_Direct_Info pointers that could be used but not modified. The lifetime of the returned pointer is until the next iteration and while the iterator is live, deleting the iterator invalidates the pointer.
- See also:
- eina_file_ls()