Ecore_File - Files and directories convenience functions
Ecore

## Typedefs

typedef struct _Ecore_File_Monitor | Ecore_File_Monitor
| Abstract type used when monitoring a directory.
typedef struct _Ecore_File_Download_Job | Ecore_File_Download_Job
| Abstract type used when aborting a download.
typedef enum _Ecore_File_Event | Ecore_File_Event
typedef void(* | Ecore_File_Monitor_Cb) (void *data, Ecore_File_Monitor *em, Ecore_File_Event event, const char *path)
| Callback type used when a monitored directory has changes.
typedef void(* | Ecore_File_Download_Completion_Cb) (void *data, const char *file, int status)
| Callback type used when a download is finished.
typedef enum _Ecore_File_Progress_Return | Ecore_File_Progress_Return
typedef int(* | Ecore_File_Download_Progress_Cb) (void *data, const char *file, long int dltotal, long int dlnow, long int ultotal, long int ulnow)
| Callback type used while a download is in progress.

## Enumerations

enum | _Ecore_File_Event { ECORE_FILE_EVENT_NONE , ECORE_FILE_EVENT_CREATED_FILE , ECORE_FILE_EVENT_CREATED_DIRECTORY , ECORE_FILE_EVENT_DELETED_FILE , ECORE_FILE_EVENT_DELETED_DIRECTORY , ECORE_FILE_EVENT_DELETED_SELF , ECORE_FILE_EVENT_MODIFIED , ECORE_FILE_EVENT_CLOSED }
| The event type returned when a file or directory is monitored. More...
enum | _Ecore_File_Progress_Return { ECORE_FILE_PROGRESS_CONTINUE = 0 , ECORE_FILE_PROGRESS_ABORT = 1 }
| What to do with the download as a return from the Ecore_File_Download_Progress_Cb function, if provided. More...

## Functions

EAPI int | ecore_file_init (void)
| Initializes the Ecore_File library.
EAPI int | ecore_file_shutdown (void)
| Shuts down the Ecore_File library.
EAPI long long | ecore_file_mod_time (const char *file)
| Gets the time of the last modification to the given file.
EAPI long long | ecore_file_size (const char *file)
| Gets the size of the given file.
EAPI Eina_Bool | ecore_file_exists (const char *file)
| Checks if the given file exists.
EAPI Eina_Bool | ecore_file_is_dir (const char *file)
| Checks if the given file is a directory.
EAPI Eina_Bool | ecore_file_mkdir (const char *dir)
| Creates a new directory.
EAPI int | ecore_file_mkdirs (const char **dirs)
| Creates complete directory in a batch.
EAPI int | ecore_file_mksubdirs (const char *base, const char **subdirs)
| Creates complete list of sub-directories in a batch (optimized).
EAPI Eina_Bool | ecore_file_rmdir (const char *dir)
| Deletes the given empty directory.
EAPI Eina_Bool | ecore_file_recursive_rm (const char *dir)
| Deletes the given directory and all its contents.
EAPI Eina_Bool | ecore_file_mkpath (const char *path)
| Creates a complete path.
EAPI int | ecore_file_mkpaths (const char **paths)
| Creates complete paths in a batch.
EAPI Eina_Bool | ecore_file_cp (const char *src, const char *dst)
| Copies the given file to the given destination.
EAPI Eina_Bool | ecore_file_mv (const char *src, const char *dst)
| Moves the given file to the given destination.
EAPI Eina_Bool | ecore_file_symlink (const char *src, const char *dest)
| Creates a symbolic link.
EAPI char * | ecore_file_realpath (const char *file)
| Gets the canonicalized absolute path name.
EAPI Eina_Bool | ecore_file_unlink (const char *file)
| Deletes the given file.
EAPI Eina_Bool | ecore_file_remove (const char *file)
| Removes the given file or directory.
EAPI const char * | ecore_file_file_get (const char *path)
| Gets the filename from a given path.
EAPI char * | ecore_file_dir_get (const char *file)
| Gets the directory where the given file resides.
EAPI Eina_Bool | ecore_file_can_read (const char *file)
| Checks if the given file can be read.
EAPI Eina_Bool | ecore_file_can_write (const char *file)
| Checks if the given file can be written.
EAPI Eina_Bool | ecore_file_can_exec (const char *file)
| Checks if the given file can be executed.
EAPI char * | ecore_file_readlink (const char *link)
| Gets the path pointed by the given link.
EAPI Eina_List * | ecore_file_ls (const char *dir)
| Gets the list of the files and directories in the given directory.
EAPI char * | ecore_file_app_exe_get (const char *app)
| Returns the executable from the given command.
EAPI char * | ecore_file_escape_name (const char *filename)
| Adds the escape sequence ('\') to the given file name.
EAPI char * | ecore_file_strip_ext (const char *path)
| Removes the extension from the given file name.
EAPI int | ecore_file_dir_is_empty (const char *dir)
| Checks if the given directory is empty.
EAPI Ecore_File_Monitor * | ecore_file_monitor_add (const char *path, Ecore_File_Monitor_Cb func, void *data)
| Monitors the given path using inotify, Windows notification, or polling.
EAPI void | ecore_file_monitor_del (Ecore_File_Monitor *em)
| Stops the monitoring of the given path.
EAPI const char * | ecore_file_monitor_path_get (Ecore_File_Monitor *em)
| Gets the monitored path.
EAPI Eina_Bool | ecore_file_path_dir_exists (const char *in_dir)
| Checks if the given directory is in PATH.
EAPI Eina_Bool | ecore_file_app_installed (const char *exe)
| Checks if the given application is installed.
EAPI Eina_List * | ecore_file_app_list (void)
| Gets a list of all the applications installed on the system.
EAPI Eina_Bool | ecore_file_download (const char *url, const char *dst, Ecore_File_Download_Completion_Cb completion_cb, Ecore_File_Download_Progress_Cb progress_cb, void *data, Ecore_File_Download_Job **job_ret)
| Downloads the given url to the given destination.
EAPI Eina_Bool | ecore_file_download_full (const char *url, const char *dst, Ecore_File_Download_Completion_Cb completion_cb, Ecore_File_Download_Progress_Cb progress_cb, void *data, Ecore_File_Download_Job **job_ret, Eina_Hash *headers)
| Downloads the given url to the given destination with additional headers.
EAPI void | ecore_file_download_abort_all (void)
| Aborts all downloads.
EAPI void | ecore_file_download_abort (Ecore_File_Download_Job *job)
| Aborts the given download job and call the completion_cb callback with a status of 1 (error).
EAPI Eina_Bool | ecore_file_download_protocol_available (const char *protocol)
| Checks if the given protocol is available.

## Detailed Description

## Enumeration Type Documentation

## _Ecore_File_Event

enum _Ecore_File_Event

The event type returned when a file or directory is monitored.

Enumerator
ECORE_FILE_EVENT_NONE | No event.
ECORE_FILE_EVENT_CREATED_FILE | Created file event.
ECORE_FILE_EVENT_CREATED_DIRECTORY | Created directory event.
ECORE_FILE_EVENT_DELETED_FILE | Deleted file event.
ECORE_FILE_EVENT_DELETED_DIRECTORY | Deleted directory event.
ECORE_FILE_EVENT_DELETED_SELF | Deleted monitored directory event.
ECORE_FILE_EVENT_MODIFIED | Modified file or directory event.
ECORE_FILE_EVENT_CLOSED | Closed file event.

## _Ecore_File_Progress_Return

enum _Ecore_File_Progress_Return

What to do with the download as a return from the Ecore_File_Download_Progress_Cb function, if provided.

Enumerator
ECORE_FILE_PROGRESS_CONTINUE | Continue the download.
ECORE_FILE_PROGRESS_ABORT | Abort the download.

## Function Documentation

## ecore_file_init()

EAPI int ecore_file_init | ( | void |  | ) |

Initializes the Ecore_File library.

Returns
  `1` or greater on success, otherwise `0` on error.

This function sets up Ecore_File and the services it will use (monitoring, downloading, PATH related feature). It returns 0 on failure, otherwise it returns the number of times it has already been called.

When Ecore_File is not used anymore, call ecore_file_shutdown() to shut down the Ecore_File library.

References ecore_init(), eina_log_domain_register(), and EINA_LOG_ERR.

Referenced by efreet_init(), elm_quicklaunch_init(), and elua_init().

## ecore_file_shutdown()

EAPI int ecore_file_shutdown | ( | void |  | ) |

Shuts down the Ecore_File library.

Returns
  `0` when the library is completely shut down, `1` or greater otherwise.

This function shuts down the Ecore_File library. It returns 0 when it has been called the same number of times than ecore_file_init(). In that case it shuts down all the services it uses.

References ecore_shutdown(), and eina_log_domain_unregister().

Referenced by efreet_init(), efreet_shutdown(), elm_quicklaunch_shutdown(), and elua_shutdown().

## ecore_file_mod_time()

EAPI long long ecore_file_mod_time | ( | const char * | file | ) |

Gets the time of the last modification to the given file.

Parameters

  file | The name of the file.

Returns
  Return the time of the last data modification, or `0` on failure.

This function returns the time of the last modification of `file`. On failure, it returns 0.

## ecore_file_size()

EAPI long long ecore_file_size | ( | const char * | file | ) |

Gets the size of the given file.

Parameters

  file | The name of the file.

Returns
  Return the size of the file in bytes, or `0` on failure.

This function returns the size of `file` in bytes. On failure, it returns 0.

Referenced by elm_theme_name_available_list_new().

## ecore_file_exists()

EAPI Eina_Bool ecore_file_exists | ( | const char * | file | ) |

Checks if the given file exists.

Parameters

  file | The name of the file.

Returns
  `EINA_TRUE` if the `file` exists, `EINA_FALSE` otherwise.

This function returns `EINA_TRUE` if `file` exists on local filesystem, `EINA_FALSE` otherwise.

References EINA_FALSE, and EINA_TRUE.

Referenced by ecore_file_download_full(), edje_available_modules_get(), edje_edit_clean_save_as(), efreet_desktop_uncached_new(), efreet_menu_get(), efreet_trash_delete_uri(), efreet_trash_dir_get(), elm_config_profile_exists(), and elm_theme_list_item_path_get().

## ecore_file_is_dir()

EAPI Eina_Bool ecore_file_is_dir | ( | const char * | file | ) |

Checks if the given file is a directory.

Parameters

  file | The name of the file.

Returns
  `EINA_TRUE` if the file exists and is a directory, `EINA_FALSE` otherwise.

This function returns `EINA_TRUE` if `file` exists exists and is a directory on local filesystem, `EINA_FALSE` otherwise.

References EINA_FALSE.

Referenced by ecore_file_app_list(), ecore_file_download_full(), ecore_file_mkpath(), ecore_file_mksubdirs(), and elm_theme_name_available_list_new().

## ecore_file_mkdir()

EAPI Eina_Bool ecore_file_mkdir | ( | const char * | dir | ) |

Creates a new directory.

Parameters

  dir | The name of the directory to create

Returns
  `EINA_TRUE` on successful creation, `EINA_FALSE` otherwise.

This function creates the directory `dir`, with the mode S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH on UNIX (mode is unused on Windows). On success, it returns `EINA_TRUE`, `EINA_FALSE` otherwise.

Referenced by ecore_file_mkdirs(), ecore_file_mksubdirs(), and efreet_trash_empty_trash().

## ecore_file_mkdirs()

EAPI int ecore_file_mkdirs | ( | const char ** | dirs | ) |

Creates complete directory in a batch.

Parameters

  dirs | The list of directories, null terminated.

Returns
  The number of successful directories created, -1 if dirs is `NULL`.

This function creates all the directories that are in the null terminated array `dirs`. The function loops over the directories and call ecore_file_mkdir(). This function returns -1 if `dirs` is `NULL`, otherwise if returns the number of successfully created directories.

References ecore_file_mkdir().

## ecore_file_mksubdirs()

EAPI int ecore_file_mksubdirs | ( | const char * | base,
|  | const char ** | subdirs )

Creates complete list of sub-directories in a batch (optimized).

Parameters

  base | The base directory to act on.
  subdirs | The list of directories, null terminated.

Returns
  The number of successful directories created, `-1` on failure.

This function creates all the directories that are in the null terminated array `subdirs` in the `base` directory. If `base` does not exist, it will be created. The function loops over the directories and call ecore_file_mkdir(). The whole path of the directories must exist. So if base/a/b/c wants to be created, `subdirs` must contain "a", "a/b" and "a/b/c", in that order. This function returns -1 if `subdirs` or `base` are `NULL`, or if `base` is empty ("\0"). It returns 0 is `base` is not a directory or invalid, or if it can't be created. Otherwise if returns the number of successfully created directories.

References ecore_file_is_dir(), ecore_file_mkdir(), ecore_file_mkpath(), and eina_strlcpy().

## ecore_file_rmdir()

EAPI Eina_Bool ecore_file_rmdir | ( | const char * | dir | ) |

Deletes the given empty directory.

Parameters

  dir | The name of the directory to delete.

Returns
  `EINA_TRUE` on success, `EINA_FALSE` otherwise.

This function deletes `dir`. It returns `EINA_TRUE` on success, `EINA_FALSE` otherwise.

References EINA_FALSE, and EINA_TRUE.

Referenced by ecore_file_recursive_rm().

## ecore_file_recursive_rm()

EAPI Eina_Bool ecore_file_recursive_rm | ( | const char * | dir | ) |

Deletes the given directory and all its contents.

Parameters

  dir | The name of the directory to delete.

Returns
  `EINA_TRUE` on success, `EINA_FALSE` otherwise.

This function delete `dir` and all its contents. If `dir` is a link only the link is removed. It returns `EINA_TRUE` on success, `EINA_FALSE` otherwise.

References ecore_file_recursive_rm(), ecore_file_rmdir(), ecore_file_unlink(), EINA_FALSE, eina_file_direct_ls(), EINA_ITERATOR_FOREACH, eina_iterator_free(), EINA_TRUE, and _Eina_File_Direct_Info::path.

Referenced by ecore_file_recursive_rm(), efreet_trash_delete_uri(), efreet_trash_empty_trash(), and elm_config_profile_derived_del().

## ecore_file_mkpath()

EAPI Eina_Bool ecore_file_mkpath | ( | const char * | path | ) |

Creates a complete path.

Parameters

  path | The path to create

Returns
  `EINA_TRUE` on success, `EINA_FALSE` otherwise.

This function creates `path` and all the subdirectories it contains. The separator is '/' or '\'. If `path` exists, this function returns `EINA_TRUE` immediately. It returns `EINA_TRUE` on success, `EINA_FALSE` otherwise.

References ecore_file_is_dir(), EINA_FALSE, EINA_SAFETY_ON_NULL_RETURN_VAL, and EINA_TRUE.

Referenced by ecore_file_mkpaths(), ecore_file_mksubdirs(), efreet_trash_dir_get(), and elm_config_all_flush().

## ecore_file_mkpaths()

EAPI int ecore_file_mkpaths | ( | const char ** | paths | ) |

Creates complete paths in a batch.

Parameters

  paths | list of paths, null terminated.

Returns
  The number of successful paths created, `-1` if paths is NULL.

This function creates all the directories that are in the null terminated array `paths`. The function loops over the directories and call ecore_file_mkpath(), hence on Windows, '\' must be replaced by '/' before calling that function. This function returns -1 if `paths` is `NULL`. Otherwise if returns the number of successfully created directories.

References ecore_file_mkpath().

## ecore_file_cp()

EAPI Eina_Bool ecore_file_cp | ( | const char * | src,
|  | const char * | dst )

Copies the given file to the given destination.

Parameters

  src | The name of the source file.
  dst | The name of the destination file.

Returns
  `EINA_TRUE` on success, `EINA_FALSE` otherwise.

This function copies `src` to `dst`. If the absolute path name of `src` and `dst` can not be computed, or if they are equal, or if the copy fails, the function returns `EINA_FALSE`, otherwise it returns `EINA_TRUE`.

References EINA_FALSE, EINA_TRUE, and realpath().

Referenced by ecore_file_mv().

## ecore_file_mv()

EAPI Eina_Bool ecore_file_mv | ( | const char * | src,
|  | const char * | dst )

Moves the given file to the given destination.

Parameters

  src | The name of the source file.
  dst | The name of the destination file.

Returns
  `EINA_TRUE` on success, `EINA_FALSE` otherwise.

This function moves `src` to `dst`. It returns `EINA_TRUE` on success, `EINA_FALSE` otherwise.

References ecore_file_cp(), ecore_file_dir_get(), ecore_file_file_get(), ecore_file_unlink(), EINA_FALSE, eina_file_mkstemp(), eina_tmpstr_del(), and EINA_TRUE.

## ecore_file_symlink()

EAPI Eina_Bool ecore_file_symlink | ( | const char * | src,
|  | const char * | dest )

Creates a symbolic link.

Parameters

  src | The name of the file to link.
  dest | The name of link.

Returns
  `EINA_TRUE` on success, `EINA_FALSE` otherwise.

This function creates the symbolic link `dest` of `src`. It returns `EINA_TRUE` on success, `EINA_FALSE` otherwise.

Note
  On windows, this function always returns `EINA_FALSE`.

References EINA_FALSE.

## ecore_file_realpath()

EAPI char * ecore_file_realpath | ( | const char * | file | ) |

Gets the canonicalized absolute path name.

Parameters

  file | The file path.

Returns
  The canonicalized absolute pathname or an empty string on failure.

This function returns the absolute path name of `file` as a newly allocated string. If `file` is `NULL`, or on error, this function returns an empty string. Otherwise, it returns the absolute path name. When not needed anymore, the returned value must be freed.

References realpath().

## ecore_file_unlink()

EAPI Eina_Bool ecore_file_unlink | ( | const char * | file | ) |

Deletes the given file.

Parameters

  file | The name of the file to delete.

Returns
  `EINA_TRUE` on success, `EINA_FALSE` otherwise.

This function deletes `file`. It returns `EINA_TRUE` on success, `EINA_FALSE` otherwise.

References EINA_FALSE, and EINA_TRUE.

Referenced by ecore_file_mv(), and ecore_file_recursive_rm().

## ecore_file_remove()

EAPI Eina_Bool ecore_file_remove | ( | const char * | file | ) |

Removes the given file or directory.

Parameters

  file | The name of the file or directory to delete.

Returns
  `EINA_TRUE` on success, `EINA_FALSE` otherwise.

This function removes `file`. It returns `EINA_TRUE` on success, `EINA_FALSE` otherwise.

References EINA_FALSE, and EINA_TRUE.

## ecore_file_file_get()

EAPI const char * ecore_file_file_get | ( | const char * | path | ) |

Gets the filename from a given path.

Parameters

  path | The complete path.

Returns
  The file name.

This function returns the file name of `path`. If `path` is `NULL`, the functions returns `NULL`.

Referenced by ecore_file_mv(), edje_edit_font_add(), edje_edit_image_add(), edje_edit_sound_sample_add(), efreet_trash_delete_uri(), efreet_util_desktop_exec_find(), elm_code_file_filename_get(), elm_quicklaunch_fork(), and elm_quicklaunch_init().

## ecore_file_dir_get()

EAPI char * ecore_file_dir_get | ( | const char * | file | ) |

Gets the directory where the given file resides.

Parameters

  file | The name of the file.

Returns
  The directory name.

This function returns the directory where `file` resides as newly allocated string. If `file` is `NULL` or on error, this function returns `NULL`. When not needed anymore, the returned value must be freed.

Referenced by ecore_file_download_full(), and ecore_file_mv().

## ecore_file_can_read()

EAPI Eina_Bool ecore_file_can_read | ( | const char * | file | ) |

Checks if the given file can be read.

Parameters

  file | The name of the file.

Returns
  `EINA_TRUE` if the `file` is readable, `EINA_FALSE` otherwise.

This function returns `EINA_TRUE` if `file` can be read, `EINA_FALSE` otherwise.

References eina_file_access(), and EINA_FILE_ACCESS_MODE_READ.

## ecore_file_can_write()

EAPI Eina_Bool ecore_file_can_write | ( | const char * | file | ) |

Checks if the given file can be written.

Parameters

  file | The name of the file.

Returns
  `EINA_TRUE` if the `file` is writable, `EINA_FALSE` otherwise.

This function returns `EINA_TRUE` if `file` can be written, `EINA_FALSE` otherwise.

References eina_file_access(), and EINA_FILE_ACCESS_MODE_WRITE.

Referenced by efreet_trash_delete_uri().

## ecore_file_can_exec()

EAPI Eina_Bool ecore_file_can_exec | ( | const char * | file | ) |

Checks if the given file can be executed.

Parameters

  file | The name of the file.

Returns
  `EINA_TRUE` if the `file` can be executed, `EINA_FALSE` otherwise.

This function returns `EINA_TRUE` if `file` can be executed, `EINA_FALSE` otherwise.

References eina_file_access(), and EINA_FILE_ACCESS_MODE_EXEC.

Referenced by ecore_file_app_installed(), and ecore_file_app_list().

## ecore_file_readlink()

EAPI char * ecore_file_readlink | ( | const char * | link | ) |

Gets the path pointed by the given link.

Parameters

  link | The name of the link.

Returns
  The path pointed by link or NULL.

This function returns the path pointed by `link` as a newly allocated string. On failure, the function returns `NULL`. When not needed anymore, the returned value must be freed.

Note
  On windows, this function always returns `NULL`.

Referenced by efreet_desktop_get().

## ecore_file_ls()

EAPI Eina_List * ecore_file_ls | ( | const char * | dir | ) |

Gets the list of the files and directories in the given directory.

Parameters

  dir | The name of the directory to list

Returns
  Return an Eina_List containing all the files in the directory; on failure it returns NULL.

This function returns a list of allocated strings of all the files and directories contained in `dir`. The list will be sorted with strcoll as compare function. That means that you may want to set the current locale for the category LC_COLLATE with setlocale(). For more information see the manual pages of strcoll and setlocale. The list will not contain the directory entries for '.' and '..'. On failure, `NULL` is returned. When not needed anymore, the list elements must be freed.

References EINA_COMPARE_CB, eina_file_direct_ls(), EINA_ITERATOR_FOREACH, eina_iterator_free(), eina_list_append(), eina_list_sort(), _Eina_File_Direct_Info::name_start, and _Eina_File_Direct_Info::path.

Referenced by ecore_file_app_list(), efreet_trash_ls(), and elm_theme_name_available_list_new().

## ecore_file_app_exe_get()

EAPI char * ecore_file_app_exe_get | ( | const char * | app | ) |

Returns the executable from the given command.

Parameters

  app | The application command, with parameters.

Returns
  The executable from `app` as a newly allocated string. Arguments are removed and escape characters are handled. If `app` is `NULL`, or on failure, the function returns `NULL`. When not needed anymore, the returned value must be freed.

References eina_environment_home_get(), EINA_FALSE, eina_strbuf_append(), eina_strbuf_append_char(), eina_strbuf_free(), eina_strbuf_new(), eina_strbuf_string_steal(), and EINA_TRUE.

Referenced by efreet_util_desktop_exec_find(), and efreet_util_desktop_exec_glob_list().

## ecore_file_escape_name()

EAPI char * ecore_file_escape_name | ( | const char * | filename | ) |

Adds the escape sequence ('\') to the given file name.

Parameters

  filename | The file name.

Returns
  The file name with special characters escaped.

This function adds the escape sequence ('\') to the given file name and returns the result as a newly allocated string. If the length of the returned string is longer than PATH_MAX, or on failure, `NULL` is returned. When not needed anymore, the returned value must be freed.

References EINA_SAFETY_ON_NULL_RETURN_VAL.

## ecore_file_strip_ext()

EAPI char * ecore_file_strip_ext | ( | const char * | path | ) |

Removes the extension from the given file name.

Parameters

  path | The name of the file.

Returns
  A newly allocated string with the extension stripped out, or `NULL` on errors.

This function removes the extension from `path` and returns the result as a newly allocated string. If `path` is `NULL`, or on failure, the function returns `NULL`. When not needed anymore, the returned value must be freed.

## ecore_file_dir_is_empty()

EAPI int ecore_file_dir_is_empty | ( | const char * | dir | ) |

Checks if the given directory is empty.

Parameters

  dir | The name of the directory to check.

Returns
  `1` if directory is empty, `0` if it has at least one file, or `-1` in case of errors.

This functions checks if `dir` is empty. The '.' and '..' files will be ignored. If `dir` is empty, 1 is returned, if it contains at least one file, `0` is returned. On failure, `-1` is returned.

References eina_file_direct_ls(), EINA_ITERATOR_FOREACH, and eina_iterator_free().

Referenced by efreet_trash_is_empty().

## ecore_file_monitor_add()

EAPI Ecore_File_Monitor * ecore_file_monitor_add | ( | const char * | path,
|  | Ecore_File_Monitor_Cb | func,
|  | void * | data )

Monitors the given path using inotify, Windows notification, or polling.

Parameters

  path | The path to monitor.
  func | The function to call on changes.
  data | The data passed to func.

Returns
  An Ecore_File_Monitor pointer or NULL on failure.

This function monitors `path`. If `path` is `NULL`, or is an empty string, or none of the notify methods (Inotify, Windows notification or polling) is available, or if `path` does not exist the function returns `NULL`. Otherwise, it returns a newly allocated Ecore_File_Monitor object and the monitoring begins. When one of the Ecore_File_Event event is notified, `func` is called and `data` is passed to `func.Call` ecore_file_monitor_del() to stop the monitoring.

References EINA_SAFETY_ON_NULL_RETURN_VAL, and EINA_SAFETY_ON_TRUE_RETURN_VAL.

Referenced by eeze_mount_tabs_watch().

## ecore_file_monitor_del()

EAPI void ecore_file_monitor_del | ( | Ecore_File_Monitor * | em | ) |

Stops the monitoring of the given path.

Parameters

  em | The Ecore_File_Monitor to stop.

This function stops the the monitoring of the path that has been monitored by ecore_file_monitor_add(). `em` must be the value returned by ecore_file_monitor_add(). If `em` is `NULL`, or none of the notify methods (Inotify, Windows notification or polling) is available this function does nothing.

References EINA_SAFETY_ON_NULL_RETURN.

Referenced by eeze_mount_tabs_unwatch().

## ecore_file_monitor_path_get()

EAPI const char * ecore_file_monitor_path_get | ( | Ecore_File_Monitor * | em | ) |

Gets the monitored path.

Parameters

  em | The Ecore_File_Monitor to query.

Returns
  The path that is monitored by `em`.

This function returns the monitored path that has been monitored by ecore_file_monitor_add(). `em` must be the value returned by ecore_file_monitor_add(). If `em` is `NULL`, the function returns `NULL`.

References EINA_SAFETY_ON_NULL_RETURN_VAL.

## ecore_file_path_dir_exists()

EAPI Eina_Bool ecore_file_path_dir_exists | ( | const char * | in_dir | ) |

Checks if the given directory is in PATH.

Parameters

  in_dir | The name of the directory to search in PATH.

Returns
  `EINA_TRUE` if the directory exist in PATH, `EINA_FALSE` otherwise.

This function checks if `in_dir` is in the environment variable PATH. If `in_dir` is `NULL`, or if PATH is empty, or `in_dir` is not in PATH, the function returns `EINA_FALSE`, otherwise it returns `EINA_TRUE`.

References EINA_FALSE, EINA_LIST_FOREACH, and EINA_TRUE.

## ecore_file_app_installed()

EAPI Eina_Bool ecore_file_app_installed | ( | const char * | exe | ) |

Checks if the given application is installed.

Parameters

  exe | The name of the application

Returns
  `EINA_TRUE` if the `exe` is in PATH and is executable, `EINA_FALSE` otherwise.

This function checks if `exe` exists in PATH and is executable. If `exe` is `NULL` or is not executable, the function returns `EINA_FALSE`, otherwise it returns `EINA_TRUE`.

References ecore_file_can_exec(), EINA_FALSE, EINA_LIST_FOREACH, and EINA_TRUE.

## ecore_file_app_list()

EAPI Eina_List * ecore_file_app_list | ( | void |  | ) |

Gets a list of all the applications installed on the system.

Returns
  An Eina_List containing all the executable files in the system.

This function returns a list of allocated strings of all the executable files. If no files are found, the function returns `NULL`. When not needed anymore, the element of the list must be freed.

References ecore_file_can_exec(), ecore_file_is_dir(), ecore_file_ls(), eina_list_append(), EINA_LIST_FOREACH, and EINA_LIST_FREE.

## ecore_file_download()

EAPI Eina_Bool ecore_file_download | ( | const char * | url,
|  | const char * | dst,
|  | Ecore_File_Download_Completion_Cb | completion_cb,
|  | Ecore_File_Download_Progress_Cb | progress_cb,
|  | void * | data,
|  | Ecore_File_Download_Job ** | job_ret )

Downloads the given url to the given destination.

Parameters

  url | The complete url to download.
  dst | The local file to save the downloaded to.
  completion_cb | A callback called on download complete.
  progress_cb | A callback called during the download operation.
  data | User data passed to both callbacks.
  job_ret | Job used to abort the download.

Returns
  `EINA_TRUE` if the download start or `EINA_FALSE` on failure.

This function starts the download of the URL `url` and saves it to `dst`. `url` must provide the protocol, including 'http://', 'ftp://' or 'file://'. Ecore_File must be compiled with CURL to download using http and ftp protocols. If `dst` is ill-formed, or if it already exists, the function returns `EINA_FALSE`. When the download is complete, the callback `completion_cb` is called and `data` is passed to it. The `status` parameter of `completion_cb` will be filled with the status of the download (200, 404,...). The `progress_cb` is called during the download operation, each time a packet is received or when CURL wants. It can be used to display the percentage of the downloaded file. Return 0 from this callback, if provided, to continue the operation or anything else to abort the download. The only operations that can be aborted are those with protocol 'http' or 'ftp'. In that case `job_ret` can be passed to ecore_file_download_abort() to abort that download job. Similarly ecore_file_download_abort_all() can be used to abort all download operations. This function returns `EINA_TRUE` if the download starts, `EINA_FALSE` otherwise.

References ecore_file_download_full().

## ecore_file_download_full()

EAPI Eina_Bool ecore_file_download_full | ( | const char * | url,
|  | const char * | dst,
|  | Ecore_File_Download_Completion_Cb | completion_cb,
|  | Ecore_File_Download_Progress_Cb | progress_cb,
|  | void * | data,
|  | Ecore_File_Download_Job ** | job_ret,
|  | Eina_Hash * | headers )

Downloads the given url to the given destination with additional headers.

Parameters

  url | The complete url to download.
  dst | The local file to save the downloaded to.
  completion_cb | A callback called on download complete.
  progress_cb | A callback called during the download operation.
  data | User data passed to both callbacks.
  job_ret | Job used to abort the download.
  headers | pointer of header lists.

Returns
  `EINA_TRUE` if the download start or `EINA_FALSE` on failure.

References ecore_file_dir_get(), ecore_file_exists(), ecore_file_is_dir(), eina_error_msg_get(), EINA_FALSE, eina_hash_foreach(), eina_list_append(), EINA_SAFETY_ON_NULL_GOTO, EINA_SAFETY_ON_NULL_RETURN_VAL, EINA_TRUE, and ERR.

Referenced by ecore_file_download().

## ecore_file_download_abort_all()

EAPI void ecore_file_download_abort_all | ( | void |  | ) |

Aborts all downloads.

This function aborts all the downloads that have been started by ecore_file_download(). It loops over the started downloads and call ecore_file_download_abort() for each of them. To abort only one specific download operation, call ecore_file_download_abort().

References ecore_file_download_abort(), and EINA_LIST_FREE.

## ecore_file_download_abort()

EAPI void ecore_file_download_abort | ( | Ecore_File_Download_Job * | job | ) |

Aborts the given download job and call the completion_cb callback with a status of 1 (error).

Parameters

  job | The download job to abort.

This function aborts a download operation started by ecore_file_download(). `job` is the Ecore_File_Download_Job structure filled by ecore_file_download(). If it is `NULL`, this function does nothing. To abort all the currently downloading operations, call ecore_file_download_abort_all().

References DBG.

Referenced by ecore_file_download_abort_all().

## ecore_file_download_protocol_available()

EAPI Eina_Bool ecore_file_download_protocol_available | ( | const char * | protocol | ) |

Checks if the given protocol is available.

Parameters

  protocol | The protocol to check.

Returns
  `EINA_TRUE` if protocol is handled, `EINA_FALSE` otherwise.

This function returns `EINA_TRUE` if `protocol` is supported, `EINA_FALSE` otherwise. `protocol` can be 'http://', 'ftp://' or 'file://'. Ecore_FILE must be compiled with CURL to handle http and ftp protocols.

References EINA_FALSE, and EINA_TRUE.