diff --git a/taglib/fileref.cpp b/taglib/fileref.cpp index ef6f745d..12abc83d 100644 --- a/taglib/fileref.cpp +++ b/taglib/fileref.cpp @@ -75,29 +75,21 @@ namespace } String ext; - -#ifdef _WIN32 - // Avoids direct conversion from FileName to String - // because String can't decode strings in local encodings properly. - - if(!fileName.wstr().empty()) { - const wchar_t *pext = PathFindExtensionW(fileName.wstr().c_str()); - if(*pext == L'.') - ext = String(pext + 1).upper(); - } - else { - const char *pext = PathFindExtensionA(fileName.str().c_str()); - if(*pext == '.') - ext = String(pext + 1).upper(); - } -#else { +#ifdef _WIN32 + + String s = fileName.toString(); + +#else + String s = fileName; - const size_t pos = s.rfind("."); - if(pos != String::npos) + +#endif + + const int pos = s.rfind("."); + if(pos != -1) ext = s.substr(pos + 1).upper(); } -#endif // If this list is updated, the method defaultFileExtensions() should also be // updated. However at some point that list should be created at the same time diff --git a/taglib/toolkit/tdebuglistener.cpp b/taglib/toolkit/tdebuglistener.cpp index 48912222..7c465bb5 100644 --- a/taglib/toolkit/tdebuglistener.cpp +++ b/taglib/toolkit/tdebuglistener.cpp @@ -43,7 +43,7 @@ namespace { #ifdef _WIN32 - const wstring wstr = msg.toWString(); + const std::wstring wstr = msg.toWString(); const int len = WideCharToMultiByte(CP_ACP, 0, wstr.c_str(), -1, NULL, 0, NULL, NULL); if(len != 0) { std::vector buf(len); diff --git a/taglib/toolkit/tiostream.cpp b/taglib/toolkit/tiostream.cpp index 0e7ea8cc..69f01227 100644 --- a/taglib/toolkit/tiostream.cpp +++ b/taglib/toolkit/tiostream.cpp @@ -139,16 +139,16 @@ const std::string &FileName::str() const String FileName::toString() const { - if(!m_wname.empty()) { - return String(m_wname); + if(!d->data->wname.empty()) { + return String(d->data->wname); } - else if(!m_name.empty()) { - const int len = MultiByteToWideChar(CP_ACP, 0, m_name.c_str(), -1, NULL, 0); + else if(!d->data->name.empty()) { + const int len = MultiByteToWideChar(CP_ACP, 0, d->data->name.c_str(), -1, NULL, 0); if(len == 0) return String::null; std::vector buf(len); - MultiByteToWideChar(CP_ACP, 0, m_name.c_str(), -1, &buf[0], len); + MultiByteToWideChar(CP_ACP, 0, d->data->name.c_str(), -1, &buf[0], len); return String(&buf[0]); }