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_PATH_MAX   8192
#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.

Enumerations

enum  Eina_File_Type {
  EINA_FILE_UNKNOWN,
  EINA_FILE_FIFO,
  EINA_FILE_CHR,
  EINA_FILE_DIR,
  EINA_FILE_BLK,
  EINA_FILE_REG,
  EINA_FILE_LNK,
  EINA_FILE_SOCK,
  EINA_FILE_WHT
}
 

file type in Eina_File_Direct_Info.

More...

Functions

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.
Eina_Arrayeina_file_split (char *path)
 Split a path according to the delimiter of the filesystem.
Eina_Iteratoreina_file_ls (const char *dir)
 Get an iterator to list the content of a directory.
Eina_Iteratoreina_file_stat_ls (const char *dir)
 Get an iterator to list the content of a directory, with direct information.
Eina_Iteratoreina_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.

This macro casts function to Eina_File_Dir_List_Cb.


Enumeration Type Documentation

file type in Eina_File_Direct_Info.

Enumerator:
EINA_FILE_UNKNOWN 

Unknown file type.

EINA_FILE_FIFO 

Named pipe (FIFO) type (unused on Windows).

EINA_FILE_CHR 

Character device type (unused on Windows).

EINA_FILE_DIR 

Directory type.

EINA_FILE_BLK 

Block device type (unused on Windows).

EINA_FILE_REG 

Regular file type.

EINA_FILE_LNK 

Symbolic link type.

EINA_FILE_SOCK 

UNIX domain socket type (unused on Windows).

EINA_FILE_WHT 

Whiteout file type (unused on Windows).


Function Documentation

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.

This function lists all the files in 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.

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.

This function splits 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.

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_r().

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.

The iterator container is the DIR* corresponding to the current walk.

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()
Eina_Iterator * eina_file_stat_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_r().

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.

The iterator container is the DIR* corresponding to the current walk.

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. It will call stat() when filesystem doesn't provide information to fill type from readdir_r().
See also:
eina_file_direct_ls()
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_r().

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.

The iterator container is the DIR* corresponding to the current walk.

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. It will not call stat() when filesystem doesn't provide information to fill type from readdir_r().
See also:
eina_file_ls()