From f2ab28386889d27a13e48e902e0f55a6bf3752c4 Mon Sep 17 00:00:00 2001 From: Jamie Dennis Date: Sat, 10 May 2025 12:12:28 +1200 Subject: [PATCH] Add file_new and file_new_type wchar variants for C binding --- bindings/c/tag_c.cpp | 23 ++++++++++++++++++++++- bindings/c/tag_c.h | 6 ++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/bindings/c/tag_c.cpp b/bindings/c/tag_c.cpp index c2d18f0a..c8550f3f 100644 --- a/bindings/c/tag_c.cpp +++ b/bindings/c/tag_c.cpp @@ -149,7 +149,15 @@ TagLib_File *taglib_file_new(const char *filename) return reinterpret_cast(new FileRef(filename)); } -TagLib_File *taglib_file_new_type(const char *filename, TagLib_File_Type type) +#ifdef _WIN32 +TagLib_File *taglib_file_new_wchar(const wchar_t *filename) +{ + return reinterpret_cast(new FileRef(filename)); +} +#endif + +template +TagLib_File *taglib_file_new_type_any_char(const T *filename, TagLib_File_Type type) { File *file = NULL; switch(type) { @@ -240,6 +248,19 @@ TagLib_File *taglib_file_new_type(const char *filename, TagLib_File_Type type) return file ? reinterpret_cast(new FileRef(file)) : NULL; } +TagLib_File *taglib_file_new_type(const char *filename, TagLib_File_Type type) +{ + return taglib_file_new_type_any_char(filename, type); +} + +#ifdef _WIN32 +TagLib_File *taglib_file_new_type_wchar(const wchar_t *filename, TagLib_File_Type type) +{ + return taglib_file_new_type_any_char(filename, type); +} +#endif + + TagLib_File *taglib_file_new_iostream(TagLib_IOStream *stream) { return reinterpret_cast( diff --git a/bindings/c/tag_c.h b/bindings/c/tag_c.h index fc6b7acc..2513f7f6 100644 --- a/bindings/c/tag_c.h +++ b/bindings/c/tag_c.h @@ -142,12 +142,18 @@ typedef enum { * be opened. */ TAGLIB_C_EXPORT TagLib_File *taglib_file_new(const char *filename); +#ifdef _WIN32 +TAGLIB_C_EXPORT TagLib_File *taglib_file_new_wchar(const wchar_t *filename); +#endif /*! * Creates a TagLib file based on \a filename. Rather than attempting to guess * the type, it will use the one specified by \a type. */ TAGLIB_C_EXPORT TagLib_File *taglib_file_new_type(const char *filename, TagLib_File_Type type); +#ifdef _WIN32 +TAGLIB_C_EXPORT TagLib_File *taglib_file_new_type_wchar(const wchar_t *filename, TagLib_File_Type type); +#endif /*! * Creates a TagLib file from a \a stream.