diff options
author | Carlos Garcia Campos <carlosgc@gnome.org> | 2010-05-11 12:29:56 (GMT) |
---|---|---|
committer | Carlos Garcia Campos <carlosgc@gnome.org> | 2010-05-11 12:29:56 (GMT) |
commit | 182e12aed96d302f78f52c16b52b8f3c2784d415 (patch) | |
tree | 94d448284806e0666266fe7f65525976603531ec | |
parent | 00f74f90ff46e9f434e12b593ac1afcbb47443bf (diff) |
[shell] Fix opening files with '#' in its name
See bug #616515.
-rw-r--r-- | shell/main.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/shell/main.c b/shell/main.c index d7d6e15..187a794 100644 --- a/shell/main.c +++ b/shell/main.c @@ -146,6 +146,28 @@ launch_previewer (void) return retval; } +static gchar * +get_label_from_filename (const gchar *filename) +{ + GFile *file; + gchar *label; + gboolean exists; + + label = g_strrstr (filename, "#"); + if (!label) + return NULL; + + /* Filename contains a #, check + * whether it's part of the path + * or a label + */ + file = g_file_new_for_commandline_arg (filename); + exists = g_file_query_exists (file, NULL); + g_object_unref (file); + + return exists ? NULL : label; +} + static void load_files (const char **files) { @@ -179,7 +201,7 @@ load_files (const char **files) const gchar *app_uri; filename = files[i]; - label = strchr (filename, '#'); + label = get_label_from_filename (filename); if (label) { *label = 0; label++; |