forked from AuroraMiddleware/gtk
Make sure icon cache has /-separated subdirs only (v2 - use g_build_path)
https://bugzilla.gnome.org/show_bug.cgi?id=692955
(cherry picked from commit 8e80fd1ab9
)
Conflicts:
gtk/updateiconcache.c
This commit is contained in:
parent
2cc67fc109
commit
d9f87ff098
@ -576,6 +576,23 @@ maybe_cache_icon_data (Image *image,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds all dir separators and replaces them with '/'.
|
||||||
|
* This makes sure that only /-separated paths are written in cache files,
|
||||||
|
* maintaining compatibility with theme index files that use slashes as
|
||||||
|
* directory separators on all platforms.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
replace_backslashes_with_slashes (gchar *path)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
if (path == NULL)
|
||||||
|
return;
|
||||||
|
for (i = 0; path[i]; i++)
|
||||||
|
if (G_IS_DIR_SEPARATOR (path[i]))
|
||||||
|
path[i] = '/';
|
||||||
|
}
|
||||||
|
|
||||||
static GList *
|
static GList *
|
||||||
scan_directory (const gchar *base_path,
|
scan_directory (const gchar *base_path,
|
||||||
const gchar *subdir,
|
const gchar *subdir,
|
||||||
@ -590,7 +607,7 @@ scan_directory (const gchar *base_path,
|
|||||||
gboolean dir_added = FALSE;
|
gboolean dir_added = FALSE;
|
||||||
guint dir_index = 0xffff;
|
guint dir_index = 0xffff;
|
||||||
|
|
||||||
dir_path = g_build_filename (base_path, subdir, NULL);
|
dir_path = g_build_path ("/", base_path, subdir, NULL);
|
||||||
|
|
||||||
/* FIXME: Use the gerror */
|
/* FIXME: Use the gerror */
|
||||||
dir = g_dir_open (dir_path, 0, NULL);
|
dir = g_dir_open (dir_path, 0, NULL);
|
||||||
@ -609,13 +626,14 @@ scan_directory (const gchar *base_path,
|
|||||||
gchar *basename, *dot;
|
gchar *basename, *dot;
|
||||||
|
|
||||||
path = g_build_filename (dir_path, name, NULL);
|
path = g_build_filename (dir_path, name, NULL);
|
||||||
|
|
||||||
retval = g_file_test (path, G_FILE_TEST_IS_DIR);
|
retval = g_file_test (path, G_FILE_TEST_IS_DIR);
|
||||||
if (retval)
|
if (retval)
|
||||||
{
|
{
|
||||||
gchar *subsubdir;
|
gchar *subsubdir;
|
||||||
|
|
||||||
if (subdir)
|
if (subdir)
|
||||||
subsubdir = g_build_filename (subdir, name, NULL);
|
subsubdir = g_build_path ("/", subdir, name, NULL);
|
||||||
else
|
else
|
||||||
subsubdir = g_strdup (name);
|
subsubdir = g_strdup (name);
|
||||||
directories = scan_directory (base_path, subsubdir, files,
|
directories = scan_directory (base_path, subsubdir, files,
|
||||||
@ -1744,6 +1762,7 @@ main (int argc, char **argv)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
g_type_init ();
|
g_type_init ();
|
||||||
|
replace_backslashes_with_slashes (path);
|
||||||
build_cache (path);
|
build_cache (path);
|
||||||
|
|
||||||
if (strcmp (var_name, "-") != 0)
|
if (strcmp (var_name, "-") != 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user