Skip to content

Commit 3ccc390

Browse files
authored
Add file_new and file_new_type wchar variants for C binding (#1271)
1 parent fbbead3 commit 3ccc390

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

bindings/c/tag_c.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,15 @@ TagLib_File *taglib_file_new(const char *filename)
149149
return reinterpret_cast<TagLib_File *>(new FileRef(filename));
150150
}
151151

152-
TagLib_File *taglib_file_new_type(const char *filename, TagLib_File_Type type)
152+
#ifdef _WIN32
153+
TagLib_File *taglib_file_new_wchar(const wchar_t *filename)
154+
{
155+
return reinterpret_cast<TagLib_File *>(new FileRef(filename));
156+
}
157+
#endif
158+
159+
template<typename T>
160+
TagLib_File *taglib_file_new_type_any_char(const T *filename, TagLib_File_Type type)
153161
{
154162
File *file = NULL;
155163
switch(type) {
@@ -240,6 +248,18 @@ TagLib_File *taglib_file_new_type(const char *filename, TagLib_File_Type type)
240248
return file ? reinterpret_cast<TagLib_File *>(new FileRef(file)) : NULL;
241249
}
242250

251+
TagLib_File *taglib_file_new_type(const char *filename, TagLib_File_Type type)
252+
{
253+
return taglib_file_new_type_any_char(filename, type);
254+
}
255+
256+
#ifdef _WIN32
257+
TagLib_File *taglib_file_new_type_wchar(const wchar_t *filename, TagLib_File_Type type)
258+
{
259+
return taglib_file_new_type_any_char(filename, type);
260+
}
261+
#endif
262+
243263
TagLib_File *taglib_file_new_iostream(TagLib_IOStream *stream)
244264
{
245265
return reinterpret_cast<TagLib_File *>(

bindings/c/tag_c.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,18 @@ typedef enum {
142142
* be opened.
143143
*/
144144
TAGLIB_C_EXPORT TagLib_File *taglib_file_new(const char *filename);
145+
#ifdef _WIN32
146+
TAGLIB_C_EXPORT TagLib_File *taglib_file_new_wchar(const wchar_t *filename);
147+
#endif
145148

146149
/*!
147150
* Creates a TagLib file based on \a filename. Rather than attempting to guess
148151
* the type, it will use the one specified by \a type.
149152
*/
150153
TAGLIB_C_EXPORT TagLib_File *taglib_file_new_type(const char *filename, TagLib_File_Type type);
154+
#ifdef _WIN32
155+
TAGLIB_C_EXPORT TagLib_File *taglib_file_new_type_wchar(const wchar_t *filename, TagLib_File_Type type);
156+
#endif
151157

152158
/*!
153159
* Creates a TagLib file from a \a stream.

0 commit comments

Comments
 (0)