diff options
author | Takamichi Horikawa <takamichiho@gmail.com> | 2017-10-22 23:37:05 +0900 |
---|---|---|
committer | Takamichi Horikawa <takamichiho@gmail.com> | 2017-10-22 23:37:05 +0900 |
commit | acb405ba36ec82511525f4f9e2a0775e2d85308e (patch) | |
tree | 6825ce49a631783b035b3613fa295d742e3254a2 /common/fmplayer_file_win.c | |
parent | abba98ed83f59263c4b952d61ce9892f9270ee67 (diff) |
Implemented filename and PCM filename display
Diffstat (limited to 'common/fmplayer_file_win.c')
-rw-r--r-- | common/fmplayer_file_win.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/common/fmplayer_file_win.c b/common/fmplayer_file_win.c index 5ca57dc..71fb263 100644 --- a/common/fmplayer_file_win.c +++ b/common/fmplayer_file_win.c @@ -114,3 +114,31 @@ void *fmplayer_path_dup(const void *pathptr) { return strdup(path); #endif } + +char *fmplayer_path_filename_sjis(const void *pathptr) { + wchar_t *u16_path = 0; + char *filename_sjis = 0; +#if defined(FMPLAYER_FILE_WIN_UTF16) + const wchar_t *path = pathptr; + u16_path = wcsdup(path); +#elif defined(FMPLAYER_FILE_WIN_UTF8) + const char *path = pathptr; + u16_path = u8tou16(path); +#endif + if (!u16_path) goto err; + PathStripPath(u16_path); + int bufsize = WideCharToMultiByte(932, 0, u16_path, -1, 0, 0, 0, 0); + if (bufsize <= 0) goto err; + filename_sjis = malloc(bufsize); + if (!filename_sjis) goto err; + bufsize = WideCharToMultiByte( + 932, 0, u16_path, -1, filename_sjis, bufsize, 0, 0); + if (!bufsize) goto err; + free(u16_path); + return filename_sjis; + +err: + free(filename_sjis); + free(u16_path); + return 0; +} |