forked from enlightenment/efl
another util function - list all executables in your $PATH - in full.
SVN revision: 18890
This commit is contained in:
parent
b1073dd01c
commit
068266c8a2
|
@ -82,7 +82,8 @@ extern "C" {
|
|||
EAPI const char *ecore_file_monitor_path_get(Ecore_File_Monitor *ecore_file_monitor);
|
||||
|
||||
EAPI int ecore_file_app_installed(const char *exe);
|
||||
|
||||
EAPI Ecore_List *ecore_file_app_list(void);
|
||||
|
||||
EAPI int ecore_file_download(const char *url, const char *dst,
|
||||
void (*completion_cb)(void *data,
|
||||
const char *file,
|
||||
|
|
|
@ -74,3 +74,32 @@ ecore_file_app_installed(const char *exe)
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Ecore_List *
|
||||
ecore_file_app_list(void)
|
||||
{
|
||||
Ecore_List *list, *files;
|
||||
char buf[PATH_MAX], *dir, *exe;
|
||||
|
||||
list = ecore_list_new();
|
||||
if (!list) return NULL;
|
||||
ecore_list_set_free_cb(list, free);
|
||||
ecore_list_goto_first(__ecore_file_path_bin);
|
||||
while ((dir = ecore_list_next(__ecore_file_path_bin)) != NULL)
|
||||
{
|
||||
files = ecore_file_ls(dir);
|
||||
if (files)
|
||||
{
|
||||
ecore_list_goto_first(files);
|
||||
while ((exe = ecore_list_next(files)) != NULL)
|
||||
{
|
||||
snprintf(buf, sizeof(buf), "%s/%s", dir, exe);
|
||||
if ((ecore_file_can_exec(buf)) &&
|
||||
(!ecore_file_is_dir(buf)))
|
||||
ecore_list_append(list, strdup(buf));
|
||||
}
|
||||
ecore_list_destroy(files);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue