Ecore_File.h File Reference
Files utility functions. More...
Functions | |
EAPI int | ecore_file_init (void) |
Initialize Ecore_File and the services it will use. | |
EAPI int | ecore_file_shutdown (void) |
Shutdown the Ecore_File. | |
EAPI long long | ecore_file_mod_time (const char *file) |
Get the time of the last modification to the give file. | |
EAPI long long | ecore_file_size (const char *file) |
Get the size of the given file. | |
EAPI int | ecore_file_exists (const char *file) |
Check if file exists. | |
EAPI int | ecore_file_is_dir (const char *file) |
Check if file is a directory. | |
EAPI int | ecore_file_mkdir (const char *dir) |
Create a new directory. | |
EAPI int | ecore_file_rmdir (const char *dir) |
Delete the given dir. | |
EAPI int | ecore_file_recursive_rm (const char *dir) |
Delete a directory and all its contents. | |
EAPI int | ecore_file_mkpath (const char *path) |
Create a complete path. | |
EAPI int | ecore_file_cp (const char *src, const char *dst) |
Copy a file. | |
EAPI int | ecore_file_mv (const char *src, const char *dst) |
Move a file. | |
EAPI int | ecore_file_symlink (const char *src, const char *dest) |
Create a symbolic link. | |
EAPI char * | ecore_file_realpath (const char *file) |
Get the canonicalized absolute pathname. | |
EAPI int | ecore_file_unlink (const char *file) |
Delete the given file. | |
EAPI const char * | ecore_file_file_get (const char *path) |
Get the filename from a give path. | |
EAPI char * | ecore_file_dir_get (const char *path) |
Get the directory where file reside. | |
EAPI int | ecore_file_can_read (const char *file) |
Check if file can be read. | |
EAPI int | ecore_file_can_write (const char *file) |
Check if file can be written. | |
EAPI int | ecore_file_can_exec (const char *file) |
Check if file can be executed. | |
EAPI char * | ecore_file_readlink (const char *link) |
Get the path pointed by link. | |
EAPI Ecore_List * | ecore_file_ls (const char *dir) |
Get the list of the files and directories in a given directory. | |
EAPI char * | ecore_file_app_exe_get (const char *app) |
FIXME: To be documented. | |
EAPI char * | ecore_file_escape_name (const char *filename) |
Add the escape sequence ('\') to the given filename. | |
EAPI char * | ecore_file_strip_ext (const char *file) |
Remove the extension from a given path. | |
EAPI int | ecore_file_dir_is_empty (const char *dir) |
Check if the given directory is empty. | |
EAPI Ecore_File_Monitor * | ecore_file_monitor_add (const char *path, void(*func)(void *data, Ecore_File_Monitor *em, Ecore_File_Event event, const char *path), void *data) |
Monitor a path using inotify or polling. | |
EAPI void | ecore_file_monitor_del (Ecore_File_Monitor *ecore_file_monitor) |
Stop monitoring a path. | |
EAPI const char * | ecore_file_monitor_path_get (Ecore_File_Monitor *ecore_file_monitor) |
Get the monitored path. | |
EAPI int | ecore_file_path_dir_exists (const char *in_dir) |
Check if the given directory is in PATH. | |
EAPI int | ecore_file_app_installed (const char *exe) |
Check if the given application is installed. | |
EAPI Ecore_List * | ecore_file_app_list (void) |
Get a list of all the applications installed on the system. | |
EAPI int | ecore_file_download (const char *url, const char *dst, void(*completion_cb)(void *data, const char *file, int status), int(*progress_cb)(void *data, const char *file, long int dltotal, long int dlnow, long int ultotal, long int ulnow), void *data) |
Download url to the given dst . | |
EAPI int | ecore_file_download_protocol_available (const char *protocol) |
Check if the given protocol is available. |
Detailed Description
Files utility functions.
Function Documentation
EAPI int ecore_file_app_installed | ( | const char * | exe | ) |
Check if the given application is installed.
- Parameters:
-
exe The name of the application
- Returns:
- 1 if the exe is in PATH and is executable
This function check if the given name exist in PATH and is executable
References ecore_file_app_installed(), ecore_list_first_goto(), and ecore_list_next().
Referenced by ecore_file_app_installed().
EAPI Ecore_List* ecore_file_app_list | ( | void | ) |
Get a list of all the applications installed on the system.
- Returns:
- An Ecore_List containing all the executable files in the system
References ecore_file_app_list(), ecore_list_append(), ecore_list_destroy(), ecore_list_first_goto(), ecore_list_free_cb_set(), ecore_list_new(), and ecore_list_next().
Referenced by ecore_file_app_list().
EAPI int ecore_file_can_exec | ( | const char * | file | ) |
Check if file can be executed.
- Parameters:
-
file The name of the file
- Returns:
- 1 if the file can be executed, 0 otherwise
EAPI int ecore_file_can_read | ( | const char * | file | ) |
Check if file can be read.
- Parameters:
-
file The name of the file
- Returns:
- 1 if the file is readable, 0 otherwise
EAPI int ecore_file_can_write | ( | const char * | file | ) |
Check if file can be written.
- Parameters:
-
file The name of the file
- Returns:
- 1 if the file is writable, 0 otherwise
EAPI int ecore_file_cp | ( | const char * | src, | |
const char * | dst | |||
) |
Copy a file.
- Parameters:
-
src The name of the source file dst The name of the destination file
- Returns:
- 1 on success, 0 on failure
EAPI char* ecore_file_dir_get | ( | const char * | file | ) |
Get the directory where file reside.
- Parameters:
-
file The name of the file
- Returns:
- The directory name
EAPI int ecore_file_dir_is_empty | ( | const char * | dir | ) |
Check if the given directory is empty.
The '.' and '..' files will be ignored.
- 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
EAPI int ecore_file_download | ( | const char * | url, | |
const char * | dst, | |||
void(*)(void *data, const char *file, int status) | completion_cb, | |||
int(*)(void *data, const char *file, long int dltotal, long int dlnow, long int ultotal, long int ulnow) | progress_cb, | |||
void * | data | |||
) |
Download url
to the given dst
.
- 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
- Returns:
- 1 if the download start or 0 on failure
You must provide the full url, including 'http://', 'ftp://' or 'file://'.
If dst
already exist it will not be overwritten and the function will fail.
Ecore must be compiled with CURL to download using http and ftp protocols.
References ecore_file_download().
Referenced by ecore_file_download().
EAPI int ecore_file_download_protocol_available | ( | const char * | protocol | ) |
Check if the given protocol is available.
- Parameters:
-
protocol The protocol to check
- Returns:
- 1 if protocol is handled or 0 if not
protocol
can be 'http://', 'ftp://' or 'file://'.
Ecore must be compiled with CURL to handle http and ftp protocols.
References ecore_file_download_protocol_available().
Referenced by ecore_file_download_protocol_available().
EAPI char* ecore_file_escape_name | ( | const char * | filename | ) |
Add the escape sequence ('\') to the given filename.
- Parameters:
-
filename The file name
- Returns:
- The file name with special characters escaped; if the length of the resulting string is longer than PATH_MAX it will return NULL
EAPI int ecore_file_exists | ( | const char * | file | ) |
Check if file exists.
- Parameters:
-
file The name of the file
- Returns:
- 1 if file exists on local filesystem, 0 otherwise
EAPI const char* ecore_file_file_get | ( | const char * | path | ) |
Get the filename from a give path.
- Parameters:
-
path The complete path
- Returns:
- Only the file name
EAPI int ecore_file_init | ( | void | ) |
Initialize Ecore_File and the services it will use.
Call this function once before you use any of the ecore file functions.
- Returns:
- Return the number howoften ecore_file_init() was call succesfully; 0 if it failed.
EAPI int ecore_file_is_dir | ( | const char * | file | ) |
Check if file is a directory.
- Parameters:
-
file The name of the file
- Returns:
- 1 if file exist and is a directory, 0 otherwise
EAPI Ecore_List* ecore_file_ls | ( | const char * | dir | ) |
Get the list of the files and directories in a given directory.
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 '..'.
- Parameters:
-
dir The name of the directory to list
- Returns:
- Return an Ecore_List containing all the files in the directory; on failure it returns NULL.
References ecore_list_append(), ecore_list_first_goto(), ecore_list_free_cb_set(), ecore_list_new(), and ecore_list_sort().
EAPI int ecore_file_mkdir | ( | const char * | dir | ) |
Create a new directory.
- Parameters:
-
dir The name of the directory to create
- Returns:
- 1 on successfull creation, 0 on failure
The directory is created with the mode: S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH
EAPI int ecore_file_mkpath | ( | const char * | path | ) |
Create a complete path.
- Parameters:
-
path The path to create
- Returns:
- 1 on success, 0 on failure
EAPI long long ecore_file_mod_time | ( | const char * | file | ) |
Get the time of the last modification to the give file.
- Parameters:
-
file The name of the file
- Returns:
- Return the time of the last data modification, if an error should occur it will return 0
EAPI Ecore_File_Monitor* ecore_file_monitor_add | ( | const char * | path, | |
void(*)(void *data, Ecore_File_Monitor *em, Ecore_File_Event event, const char *path) | func, | |||
void * | data | |||
) |
Monitor a path using inotify 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
References ecore_file_monitor_add().
Referenced by ecore_file_monitor_add().
EAPI void ecore_file_monitor_del | ( | Ecore_File_Monitor * | em | ) |
Stop monitoring a path.
- Parameters:
-
em The Ecore_File_Monitor to stop
References ecore_file_monitor_del().
Referenced by ecore_file_monitor_del().
EAPI const char* ecore_file_monitor_path_get | ( | Ecore_File_Monitor * | em | ) |
Get the monitored path.
- Parameters:
-
em The Ecore_File_Monitor to query
- Returns:
- The path that is monitored by
em
References ecore_file_monitor_path_get().
Referenced by ecore_file_monitor_path_get().
EAPI int ecore_file_mv | ( | const char * | src, | |
const char * | dst | |||
) |
Move a file.
- Parameters:
-
src The name of the source file dst The name of the destination file
- Returns:
- 1 on success, 0 on failure
EAPI int ecore_file_path_dir_exists | ( | const char * | in_dir | ) |
Check if the given directory is in PATH.
- Parameters:
-
The name of the directory to search in PATH
- Returns:
- 1 if the directory exist in PATH, 0 otherwise
References ecore_file_path_dir_exists(), ecore_list_first_goto(), and ecore_list_next().
Referenced by ecore_file_path_dir_exists().
EAPI char* ecore_file_readlink | ( | const char * | link | ) |
Get the path pointed by link.
- Parameters:
-
link The name of the link
- Returns:
- The path pointed by link or NULL
EAPI char* ecore_file_realpath | ( | const char * | file | ) |
Get the canonicalized absolute pathname.
- Parameters:
-
file The file path
- Returns:
- The canonicalized absolute pathname; on failure it will return an empty string
EAPI int ecore_file_recursive_rm | ( | const char * | dir | ) |
Delete a directory and all its contents.
- Parameters:
-
dir The name of the directory to delete
- Returns:
- 1 on success, 0 on failure
If dir is a link only the link is removed
EAPI int ecore_file_rmdir | ( | const char * | dir | ) |
Delete the given dir.
- Parameters:
-
dir The name of the directory to delete
- Returns:
- 1 on success, 0 on failure
EAPI int ecore_file_shutdown | ( | void | ) |
Shutdown the Ecore_File.
- Returns:
- returns the number of libraries that still uses Ecore_File
EAPI long long ecore_file_size | ( | const char * | file | ) |
Get the size of the given file.
- Parameters:
-
file The name of the file
- Returns:
- The size of the file in byte
EAPI char* ecore_file_strip_ext | ( | const char * | path | ) |
Remove the extension from a given path.
- Parameters:
-
path The name of the file
- Returns:
- A newly allocated string with the extension stripped out or NULL on errors
EAPI int ecore_file_symlink | ( | const char * | src, | |
const char * | dest | |||
) |
Create a symbolic link.
- Parameters:
-
src The name of the file to link dest The name of link
- Returns:
- 1 on success, 0 on failure
EAPI int ecore_file_unlink | ( | const char * | file | ) |
Delete the given file.
- Parameters:
-
file The name of the file to delete
- Returns:
- 1 on success, 0 on failure