aboutsummaryrefslogtreecommitdiff
path: root/common/fmplayer_file_gio.c
diff options
context:
space:
mode:
authorTakamichi Horikawa <takamichiho@gmail.com>2017-10-22 23:37:05 +0900
committerTakamichi Horikawa <takamichiho@gmail.com>2017-10-22 23:37:05 +0900
commitacb405ba36ec82511525f4f9e2a0775e2d85308e (patch)
tree6825ce49a631783b035b3613fa295d742e3254a2 /common/fmplayer_file_gio.c
parentabba98ed83f59263c4b952d61ce9892f9270ee67 (diff)
Implemented filename and PCM filename display
Diffstat (limited to 'common/fmplayer_file_gio.c')
-rw-r--r--common/fmplayer_file_gio.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/common/fmplayer_file_gio.c b/common/fmplayer_file_gio.c
index a2b52d2..c690b15 100644
--- a/common/fmplayer_file_gio.c
+++ b/common/fmplayer_file_gio.c
@@ -1,5 +1,6 @@
#include "common/fmplayer_file.h"
#include <gio/gio.h>
+#include <glib.h>
#include <stdlib.h>
#include <string.h>
@@ -119,3 +120,34 @@ err:
void *fmplayer_path_dup(const void *path) {
return strdup(path);
}
+
+char *fmplayer_path_filename_sjis(const void *pathptr) {
+ const char *uri = pathptr;
+ GFile *file = 0;
+ GFileInfo *finfo = 0;
+ const char *filename = 0;
+ char *filenamesjis = 0, *filenamebuf = 0;
+ file = g_file_new_for_uri(uri);
+ if (!file) goto err;
+ finfo = g_file_query_info(
+ file,
+ G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME,
+ G_FILE_QUERY_INFO_NONE,
+ 0,
+ 0);
+ if (!finfo) goto err;
+ filename = g_file_info_get_attribute_string(
+ finfo, G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME);
+ filenamesjis = g_convert_with_fallback(
+ filename, -1,
+ "cp932", "utf-8", "?",
+ 0, 0, 0);
+ if (!filenamesjis) goto err;
+ filenamebuf = strdup(filenamesjis);
+err:
+ if (filenamesjis) g_free(filenamesjis);
+ if (finfo) g_object_unref(G_OBJECT(finfo));
+ if (file) g_object_unref(G_OBJECT(file));
+ return filenamebuf;
+}
+