changeset 1277:e7cd962732cb

file_name and file_path in a tuple should be unescaped.
author Yoshiki Yazawa <yaz@cc.rim.or.jp>
date Mon, 16 Jul 2007 16:16:41 +0900
parents 504c0dc36c0a
children d1c66f8ccf73
files src/madplug/input.c src/madplug/plugin.c
diffstat 2 files changed, 23 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/src/madplug/input.c	Mon Jul 16 00:24:09 2007 +0200
+++ b/src/madplug/input.c	Mon Jul 16 16:16:41 2007 +0900
@@ -352,6 +352,7 @@
 static void input_read_tag(struct mad_info_t *info)
 {
     gchar *string = NULL;
+    gchar *realfn = NULL;
     TitleInput *title_input;
     glong curpos = 0;
 
@@ -425,9 +426,11 @@
         g_free(string);
         string = NULL;
     }
-
-    title_input->file_name = g_strdup(g_basename(info->filename));
-    title_input->file_path = g_path_get_dirname(info->filename);
+    
+    realfn = g_filename_from_uri(info->filename, NULL, NULL);
+    title_input->file_name = g_strdup(g_basename(realfn ? realfn : info->filename));
+    title_input->file_path = g_path_get_dirname(realfn ? realfn : info->filename);
+    g_free(realfn); realfn = NULL;
     if ((string = strrchr(title_input->file_name, '.'))) {
         title_input->file_ext = string + 1;
         *string = '\0';         // make filename end at dot.
--- a/src/madplug/plugin.c	Mon Jul 16 00:24:09 2007 +0200
+++ b/src/madplug/plugin.c	Mon Jul 16 16:16:41 2007 +0900
@@ -601,6 +601,7 @@
 {
     TitleInput *tuple = NULL;
     gchar *string = NULL;
+    gchar *realfn = NULL;
 
     struct id3_file *id3file = NULL;
     struct id3_tag *tag = NULL;
@@ -635,9 +636,12 @@
             g_message("audmad_get_song_tuple: track_name = %s", tuple->track_name);
             g_message("audmad_get_song_tuple: stream_name = %s", tuple->album_name);
 #endif
-            tuple->file_name = g_path_get_basename(filename);
-            tuple->file_path = g_path_get_dirname(filename);
-            tuple->file_ext = extname(filename);
+            realfn = g_filename_from_uri(filename, NULL, NULL);
+            tuple->file_name = g_path_get_basename(realfn ? realfn : filename);
+            tuple->file_path = g_path_get_dirname(realfn ? realfn : filename);
+            tuple->file_ext = extname(realfn ? realfn : filename);
+            g_free(realfn); realfn = NULL;
+
             tuple->length = -1;
             tuple->mtime = 0; // this indicates streaming
 #ifdef DEBUG
@@ -676,10 +680,11 @@
                 g_free(string);
                 string = NULL;
             }
-
-            tuple->file_name = g_path_get_basename(filename);
-            tuple->file_path = g_path_get_dirname(filename);
-            tuple->file_ext = extname(filename);
+            realfn = g_filename_from_uri(filename, NULL, NULL);
+            tuple->file_name = g_path_get_basename(realfn ? realfn : filename);
+            tuple->file_path = g_path_get_dirname(realfn ? realfn : filename);
+            tuple->file_ext = extname(realfn ? realfn : filename);
+            g_free(realfn); realfn = NULL;
 
             // length
             tuple->length = -1;
@@ -720,9 +725,11 @@
         id3_file_close(id3file);
     }
     else { // no id3tag
-        tuple->file_name = g_path_get_basename(filename);
-        tuple->file_path = g_path_get_dirname(filename);
-        tuple->file_ext = extname(filename);
+        realfn = g_filename_from_uri(filename, NULL, NULL);
+        tuple->file_name = g_path_get_basename(realfn ? realfn : filename);
+        tuple->file_path = g_path_get_dirname(realfn ? realfn : filename);
+        tuple->file_ext = extname(realfn ? realfn : filename);
+        g_free(realfn); realfn = NULL;
         // length
         {
             char *dummy = NULL;