2008-05-25 22:16:34 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
2012-11-23 14:38:23 -08:00
|
|
|
#ifdef STDC_HEADERS
|
|
|
|
# include <stdlib.h>
|
|
|
|
# include <stddef.h>
|
|
|
|
#else
|
|
|
|
# ifdef HAVE_STDLIB_H
|
|
|
|
# include <stdlib.h>
|
|
|
|
# endif
|
|
|
|
#endif
|
2010-11-26 00:06:19 -08:00
|
|
|
#ifdef HAVE_ALLOCA_H
|
|
|
|
# include <alloca.h>
|
2012-11-23 14:38:23 -08:00
|
|
|
#elif !defined alloca
|
|
|
|
# ifdef __GNUC__
|
|
|
|
# define alloca __builtin_alloca
|
|
|
|
# elif defined _AIX
|
|
|
|
# define alloca __alloca
|
|
|
|
# elif defined _MSC_VER
|
|
|
|
# include <malloc.h>
|
|
|
|
# define alloca _alloca
|
|
|
|
# elif !defined HAVE_ALLOCA
|
|
|
|
# ifdef __cplusplus
|
2010-11-26 00:06:19 -08:00
|
|
|
extern "C"
|
2012-11-23 14:38:23 -08:00
|
|
|
# endif
|
2010-11-26 00:06:19 -08:00
|
|
|
void *alloca (size_t);
|
2012-11-23 14:38:23 -08:00
|
|
|
# endif
|
2010-11-26 00:06:19 -08:00
|
|
|
#endif
|
|
|
|
|
2011-12-06 08:09:05 -08:00
|
|
|
#include <stdlib.h>
|
2009-01-31 10:33:39 -08:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2005-06-11 06:29:09 -07:00
|
|
|
#include "ecore_file_private.h"
|
|
|
|
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
static Eina_List *__ecore_file_path_bin = NULL;
|
2005-06-11 06:29:09 -07:00
|
|
|
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
static Eina_List *_ecore_file_path_from_env(const char *env);
|
2005-06-11 06:29:09 -07:00
|
|
|
|
2009-10-09 22:28:43 -07:00
|
|
|
void
|
2005-06-11 06:29:09 -07:00
|
|
|
ecore_file_path_init(void)
|
|
|
|
{
|
|
|
|
__ecore_file_path_bin = _ecore_file_path_from_env("PATH");
|
|
|
|
}
|
|
|
|
|
2009-10-09 22:28:43 -07:00
|
|
|
void
|
2005-06-11 06:29:09 -07:00
|
|
|
ecore_file_path_shutdown(void)
|
|
|
|
{
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
char *dir;
|
|
|
|
|
|
|
|
EINA_LIST_FREE(__ecore_file_path_bin, dir)
|
2010-10-28 04:31:30 -07:00
|
|
|
eina_stringshare_del(dir);
|
2005-06-11 06:29:09 -07:00
|
|
|
}
|
|
|
|
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
Eina_List *
|
2005-06-11 06:29:09 -07:00
|
|
|
_ecore_file_path_from_env(const char *env)
|
|
|
|
{
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
Eina_List *path = NULL;
|
2010-11-09 06:09:16 -08:00
|
|
|
char *env_tmp, *env_path, *p, *last;
|
2005-06-11 06:29:09 -07:00
|
|
|
|
2010-11-09 06:09:16 -08:00
|
|
|
env_tmp = getenv(env);
|
|
|
|
if (!env_tmp)
|
2005-06-11 06:29:09 -07:00
|
|
|
return path;
|
|
|
|
|
2010-11-18 10:45:39 -08:00
|
|
|
env_path = alloca(sizeof(char) * strlen(env_tmp) + 1);
|
|
|
|
memset(env_path, 0, strlen(env_tmp));
|
2010-11-09 06:09:16 -08:00
|
|
|
strcpy(env_path, env_tmp);
|
2005-06-11 06:29:09 -07:00
|
|
|
last = env_path;
|
|
|
|
for (p = env_path; *p; p++)
|
|
|
|
{
|
|
|
|
if (*p == ':')
|
|
|
|
*p = '\0';
|
|
|
|
|
|
|
|
if (!*p)
|
|
|
|
{
|
2010-09-30 00:25:06 -07:00
|
|
|
if (!ecore_file_path_dir_exists(last))
|
2010-10-28 04:31:30 -07:00
|
|
|
path = eina_list_append(path, eina_stringshare_add(last));
|
2005-09-27 22:57:41 -07:00
|
|
|
last = p + 1;
|
2005-06-11 06:29:09 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (p > last)
|
2010-10-28 04:31:30 -07:00
|
|
|
path = eina_list_append(path, eina_stringshare_add(last));
|
2005-06-11 06:29:09 -07:00
|
|
|
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
2007-08-06 13:00:28 -07:00
|
|
|
/**
|
2011-01-27 12:40:02 -08:00
|
|
|
* @addtogroup Ecore_File_Group Ecore_File - Files and directories convenience functions
|
2010-10-23 04:05:36 -07:00
|
|
|
*
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Check if the given directory is in PATH.
|
|
|
|
*
|
2012-01-17 03:37:35 -08:00
|
|
|
* @param in_dir The name of the directory to search in PATH.
|
2012-04-11 20:51:36 -07:00
|
|
|
* @return @c EINA_TRUE if the directory exist in PATH, @c EINA_FALSE otherwise.
|
2010-10-23 04:05:36 -07:00
|
|
|
*
|
|
|
|
* This function checks if @p in_dir is in the environment variable
|
|
|
|
* PATH. If @p in_dir is @c NULL, or if PATH is empty, or @p in_dir is
|
2012-04-11 20:51:36 -07:00
|
|
|
* not in PATH, the function returns @c EINA_FALSE, otherwise it returns
|
|
|
|
* @c EINA_TRUE.
|
2007-08-06 13:00:28 -07:00
|
|
|
*/
|
2010-09-24 22:34:26 -07:00
|
|
|
EAPI Eina_Bool
|
2006-01-19 01:32:18 -08:00
|
|
|
ecore_file_path_dir_exists(const char *in_dir)
|
|
|
|
{
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
Eina_List *l;
|
2006-01-19 01:32:18 -08:00
|
|
|
char *dir;
|
2006-01-20 18:12:51 -08:00
|
|
|
|
2010-10-23 04:05:36 -07:00
|
|
|
if (!in_dir)
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
2010-09-24 22:34:26 -07:00
|
|
|
if (!__ecore_file_path_bin) return EINA_FALSE;
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
EINA_LIST_FOREACH(__ecore_file_path_bin, l, dir)
|
2006-01-19 01:32:18 -08:00
|
|
|
{
|
2010-09-30 00:25:06 -07:00
|
|
|
if (strcmp(dir, in_dir))
|
|
|
|
return EINA_TRUE;
|
2006-01-19 01:32:18 -08:00
|
|
|
}
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
|
2010-09-24 22:34:26 -07:00
|
|
|
return EINA_FALSE;
|
2006-01-19 01:32:18 -08:00
|
|
|
}
|
|
|
|
|
2007-08-06 13:00:28 -07:00
|
|
|
/**
|
2010-10-23 04:05:36 -07:00
|
|
|
* @brief Check if the given application is installed.
|
|
|
|
*
|
2007-08-06 13:00:28 -07:00
|
|
|
* @param exe The name of the application
|
2012-04-11 20:51:36 -07:00
|
|
|
* @return @c EINA_TRUE if the @p exe is in PATH and is executable,
|
|
|
|
* @c EINA_FALSE otherwise.
|
2011-04-20 07:15:33 -07:00
|
|
|
*
|
2010-10-23 04:05:36 -07:00
|
|
|
* This function checks if @p exe exists in PATH and is executable. If
|
|
|
|
* @p exe is @c NULL or is not executable, the function returns
|
2012-04-11 20:51:36 -07:00
|
|
|
* @c EINA_FALSE, otherwise it returns @c EINA_TRUE.
|
2007-08-06 13:00:28 -07:00
|
|
|
*/
|
2010-09-24 22:34:26 -07:00
|
|
|
EAPI Eina_Bool
|
2005-09-27 22:57:41 -07:00
|
|
|
ecore_file_app_installed(const char *exe)
|
2005-06-11 06:29:09 -07:00
|
|
|
{
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
Eina_List *l;
|
2005-06-11 06:29:09 -07:00
|
|
|
char *dir;
|
2005-09-29 10:50:04 -07:00
|
|
|
char buf[PATH_MAX];
|
2005-06-11 06:29:09 -07:00
|
|
|
|
2010-09-24 22:34:26 -07:00
|
|
|
if (!exe) return EINA_FALSE;
|
|
|
|
if (ecore_file_can_exec(exe)) return EINA_TRUE;
|
2005-06-11 06:29:09 -07:00
|
|
|
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
EINA_LIST_FOREACH(__ecore_file_path_bin, l, dir)
|
2005-06-11 06:29:09 -07:00
|
|
|
{
|
2010-09-30 00:25:06 -07:00
|
|
|
snprintf(buf, sizeof(buf), "%s/%s", dir, exe);
|
|
|
|
if (ecore_file_can_exec(buf))
|
|
|
|
return EINA_TRUE;
|
2005-06-11 06:29:09 -07:00
|
|
|
}
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
|
2010-09-24 22:34:26 -07:00
|
|
|
return EINA_FALSE;
|
2005-09-27 22:57:41 -07:00
|
|
|
}
|
2005-12-06 23:18:52 -08:00
|
|
|
|
2007-08-06 13:00:28 -07:00
|
|
|
/**
|
2010-10-23 04:05:36 -07:00
|
|
|
* @brief Get a list of all the applications installed on the system.
|
|
|
|
*
|
|
|
|
* @return 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
|
|
|
|
* @c NULL. When not needed anymore, the element of the list must be
|
|
|
|
* freed.
|
2007-08-06 13:00:28 -07:00
|
|
|
*/
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
EAPI Eina_List *
|
2005-12-06 23:18:52 -08:00
|
|
|
ecore_file_app_list(void)
|
|
|
|
{
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
Eina_List *list = NULL;
|
|
|
|
Eina_List *files;
|
|
|
|
Eina_List *l;
|
2005-12-06 23:18:52 -08:00
|
|
|
char buf[PATH_MAX], *dir, *exe;
|
2011-04-20 07:15:33 -07:00
|
|
|
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
EINA_LIST_FOREACH(__ecore_file_path_bin, l, dir)
|
2005-12-06 23:18:52 -08:00
|
|
|
{
|
2010-09-30 00:25:06 -07:00
|
|
|
files = ecore_file_ls(dir);
|
|
|
|
EINA_LIST_FREE(files, exe)
|
|
|
|
{
|
|
|
|
snprintf(buf, sizeof(buf), "%s/%s", dir, exe);
|
|
|
|
if ((ecore_file_can_exec(buf)) &&
|
|
|
|
(!ecore_file_is_dir(buf)))
|
|
|
|
list = eina_list_append(list, strdup(buf));
|
|
|
|
free(exe);
|
|
|
|
}
|
2005-12-06 23:18:52 -08:00
|
|
|
}
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
|
2005-12-06 23:18:52 -08:00
|
|
|
return list;
|
|
|
|
}
|
2010-10-23 04:05:36 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|