minor speedups.
the e_main.c change might prove useful as it will minimize path resolution a lot, something that is not that cheap, even more durin e startup where disc is still spinning due other tasks starting. HOWEVER, it might bring problems to those using pre GLibC-2.4 (we're at 2.9 these days) and maybe people using Solaris or BSD, let's see if they have any trouble. SVN revision: 39880
This commit is contained in:
parent
9533dd4543
commit
d68e3158cf
|
@ -1100,13 +1100,19 @@ EAPI Eina_List *
|
||||||
e_config_profile_list(void)
|
e_config_profile_list(void)
|
||||||
{
|
{
|
||||||
Eina_List *files;
|
Eina_List *files;
|
||||||
char buf[PATH_MAX];
|
char buf[PATH_MAX], *p;
|
||||||
const char *homedir;
|
const char *homedir;
|
||||||
const char *dir;
|
const char *dir;
|
||||||
Eina_List *flist = NULL;
|
Eina_List *flist = NULL;
|
||||||
|
int len;
|
||||||
|
|
||||||
homedir = e_user_homedir_get();
|
homedir = e_user_homedir_get();
|
||||||
snprintf(buf, sizeof(buf), "%s/.e/e/config/", homedir);
|
len = snprintf(buf, sizeof(buf), "%s/.e/e/config/", homedir);
|
||||||
|
if (len >= (int)sizeof(buf))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
p = buf + len;
|
||||||
|
len = sizeof(buf) - len;
|
||||||
files = ecore_file_ls(buf);
|
files = ecore_file_ls(buf);
|
||||||
if (files)
|
if (files)
|
||||||
{
|
{
|
||||||
|
@ -1115,7 +1121,11 @@ e_config_profile_list(void)
|
||||||
files = eina_list_sort(files, 0, (Eina_Compare_Cb)_cb_sort_files);
|
files = eina_list_sort(files, 0, (Eina_Compare_Cb)_cb_sort_files);
|
||||||
EINA_LIST_FREE(files, file)
|
EINA_LIST_FREE(files, file)
|
||||||
{
|
{
|
||||||
snprintf(buf, sizeof(buf), "%s/.e/e/config/%s", homedir, file);
|
if (ecore_strlcpy(p, file, len) >= len)
|
||||||
|
{
|
||||||
|
free(file);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (ecore_file_is_dir(buf))
|
if (ecore_file_is_dir(buf))
|
||||||
flist = eina_list_append(flist, file);
|
flist = eina_list_append(flist, file);
|
||||||
else
|
else
|
||||||
|
@ -1123,21 +1133,28 @@ e_config_profile_list(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dir = e_prefix_data_get();
|
dir = e_prefix_data_get();
|
||||||
snprintf(buf, sizeof(buf), "%s/data/config", dir);
|
len = snprintf(buf, sizeof(buf), "%s/data/config", dir);
|
||||||
|
if (len >= (int)sizeof(buf))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
p = buf + len;
|
||||||
|
len = sizeof(buf) - len;
|
||||||
files = ecore_file_ls(buf);
|
files = ecore_file_ls(buf);
|
||||||
if (files)
|
if (files)
|
||||||
{
|
{
|
||||||
char *file;
|
char *file;
|
||||||
|
|
||||||
files = eina_list_sort(files, 0, (Eina_Compare_Cb)_cb_sort_files);
|
files = eina_list_sort(files, 0, (Eina_Compare_Cb)_cb_sort_files);
|
||||||
EINA_LIST_FREE(files, file)
|
EINA_LIST_FREE(files, file)
|
||||||
{
|
{
|
||||||
const char *tmp;
|
if (ecore_strlcpy(p, file, len) >= len)
|
||||||
Eina_List *l;
|
{
|
||||||
|
free(file);
|
||||||
snprintf(buf, sizeof(buf), "%s/data/config/%s", dir, file);
|
continue;
|
||||||
|
}
|
||||||
if (ecore_file_is_dir(buf))
|
if (ecore_file_is_dir(buf))
|
||||||
{
|
{
|
||||||
|
const Eina_List *l;
|
||||||
|
const char *tmp;
|
||||||
EINA_LIST_FOREACH(flist, l, tmp)
|
EINA_LIST_FOREACH(flist, l, tmp)
|
||||||
if (!strcmp(file, tmp)) break;
|
if (!strcmp(file, tmp)) break;
|
||||||
|
|
||||||
|
|
122
src/bin/e_main.c
122
src/bin/e_main.c
|
@ -1,12 +1,17 @@
|
||||||
/*
|
/*
|
||||||
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
|
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
|
||||||
*/
|
*/
|
||||||
|
#define _GNU_SOURCE
|
||||||
#include "e.h"
|
#include "e.h"
|
||||||
|
|
||||||
#ifdef HAVE_ECORE_IMF
|
#ifdef HAVE_ECORE_IMF
|
||||||
#include <Ecore_IMF.h>
|
#include <Ecore_IMF.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* i need to make more use of these when i'm baffled as to when something is
|
* i need to make more use of these when i'm baffled as to when something is
|
||||||
* up. other hooks:
|
* up. other hooks:
|
||||||
|
@ -1151,53 +1156,108 @@ _e_main_x_shutdown(void)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static mode_t default_mode = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_e_main_dirs_init(void)
|
_e_main_dirs_init(void)
|
||||||
{
|
{
|
||||||
const char *homedir;
|
const char *homedir;
|
||||||
char buf[PATH_MAX];
|
char buf[PATH_MAX];
|
||||||
const char *dirs[] =
|
const char *dirs[] = {
|
||||||
{
|
"images",
|
||||||
"%s/.e",
|
"fonts",
|
||||||
"%s/.e/e/",
|
"themes",
|
||||||
"%s/.e/e/images",
|
"icons",
|
||||||
"%s/.e/e/fonts",
|
"backgrounds",
|
||||||
"%s/.e/e/themes",
|
"applications",
|
||||||
"%s/.e/e/icons",
|
"applications/menu",
|
||||||
"%s/.e/e/backgrounds",
|
"applications/menu/favorite",
|
||||||
"%s/.e/e/applications",
|
"applications/menu/all",
|
||||||
"%s/.e/e/applications/menu",
|
"applications/bar",
|
||||||
"%s/.e/e/applications/menu/favorite",
|
"applications/bar/default",
|
||||||
"%s/.e/e/applications/menu/all",
|
"applications/startup",
|
||||||
"%s/.e/e/applications/bar",
|
"applications/restart",
|
||||||
"%s/.e/e/applications/bar/default",
|
"applications/trash",
|
||||||
"%s/.e/e/applications/startup",
|
"modules",
|
||||||
"%s/.e/e/applications/restart",
|
"config",
|
||||||
"%s/.e/e/applications/trash",
|
"locale",
|
||||||
"%s/.e/e/modules",
|
"input_methods"
|
||||||
"%s/.e/e/config",
|
|
||||||
"%s/.e/e/locale",
|
|
||||||
"%s/.e/e/input_methods"
|
|
||||||
};
|
};
|
||||||
int i;
|
int i, fd, baselen, retval;
|
||||||
|
DIR *dir;
|
||||||
|
|
||||||
homedir = e_user_homedir_get();
|
homedir = e_user_homedir_get();
|
||||||
|
baselen = snprintf(buf, sizeof(buf), "%s/.e/e", homedir);
|
||||||
|
if (baselen >= (int)sizeof(buf))
|
||||||
|
{
|
||||||
|
e_error_message_show("Error could not join:\n'%s'\nand\n'/.e/e",
|
||||||
|
homedir);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if ((!ecore_file_is_dir(buf)) && (!ecore_file_mkpath(buf)))
|
||||||
|
{
|
||||||
|
e_error_message_show("Error creating directory:\n%s", buf);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
dir = opendir(buf);
|
||||||
|
if (!dir)
|
||||||
|
{
|
||||||
|
e_error_message_show("Could not open:\n%s\nError: %s",
|
||||||
|
buf, strerror(errno));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
fd = dirfd(dir);
|
||||||
|
|
||||||
|
buf[baselen] = '/';
|
||||||
|
baselen++;
|
||||||
|
buf[baselen] = '\0';
|
||||||
|
retval = 1;
|
||||||
for (i = 0; i < (int)(sizeof(dirs) / sizeof(char *)); i++)
|
for (i = 0; i < (int)(sizeof(dirs) / sizeof(char *)); i++)
|
||||||
{
|
{
|
||||||
snprintf(buf, sizeof(buf), dirs[i], homedir);
|
/* TODO: probably need to handle cases without ATSOURCE files?
|
||||||
if (!ecore_file_mkdir(buf))
|
* let's wait people to report and if any I'll fix it.
|
||||||
|
*/
|
||||||
|
struct stat st;
|
||||||
|
if (fstatat(fd, dirs[i], &st, 0) == 0)
|
||||||
{
|
{
|
||||||
if (!ecore_file_is_dir(buf))
|
if (S_ISDIR(st.st_mode))
|
||||||
|
continue;
|
||||||
|
else
|
||||||
{
|
{
|
||||||
e_error_message_show("Error creating directory:\n"
|
e_error_message_show("Not a directory:\n%s%s", buf, dirs[i]);
|
||||||
"%s",
|
retval = 0;
|
||||||
buf);
|
goto end;
|
||||||
return 0;
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (errno == ENOENT)
|
||||||
|
{
|
||||||
|
if (mkdirat(fd, dirs[i], default_mode) == 0)
|
||||||
|
continue;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
e_error_message_show
|
||||||
|
("could not create dir:\n%s%s\nError: %s",
|
||||||
|
buf, dirs[i], strerror(errno));
|
||||||
|
retval = 0;
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
e_error_message_show("could not fstat:\n%s%s\nError: %s",
|
||||||
|
buf, dirs[i], strerror(errno));
|
||||||
|
retval = 0;
|
||||||
|
goto end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
end:
|
||||||
|
closedir(dir);
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
Loading…
Reference in New Issue