mirror of
https://github.com/taglib/taglib.git
synced 2025-05-27 21:20:26 -04:00
Small change in Win9x support
This commit is contained in:
parent
d06f480f82
commit
36d9fc1973
@ -29,30 +29,26 @@ using namespace TagLib;
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
// MSVC 2008 or later can't produce the binary for Win9x.
|
||||
#if !defined(_MSC_VER) || (_MSC_VER < 1500)
|
||||
# include <windows.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
// Check if the running system has CreateFileW() function.
|
||||
// Windows9x systems don't have CreateFileW() or can't accept Unicode file names.
|
||||
|
||||
// Determines whether or not the running system is WinNT.
|
||||
// In other words, whether the system supports Unicode.
|
||||
|
||||
bool isWinNT()
|
||||
bool supportsUnicode()
|
||||
{
|
||||
OSVERSIONINFOA ver = {};
|
||||
ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
|
||||
if(GetVersionExA(&ver)) {
|
||||
return (ver.dwPlatformId == VER_PLATFORM_WIN32_NT);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
const FARPROC p = GetProcAddress(GetModuleHandleA("kernel32"), "CreateFileW");
|
||||
return (p != NULL);
|
||||
}
|
||||
|
||||
// Indicates whether the system supports Unicode file names.
|
||||
|
||||
const bool IsWinNT = isWinNT();
|
||||
const bool SystemSupportsUnicode = supportsUnicode();
|
||||
|
||||
// Converts a UTF-16 string into a local encoding.
|
||||
// This function should only be used in Windows9x systems which don't support
|
||||
// Unicode file names.
|
||||
|
||||
std::string unicodeToAnsi(const std::wstring &wstr)
|
||||
{
|
||||
@ -71,20 +67,11 @@ namespace
|
||||
// If Win9x, converts and stores it into m_name to avoid calling Unicode version functions.
|
||||
|
||||
FileName::FileName(const wchar_t *name)
|
||||
: m_wname(IsWinNT ? name : L"")
|
||||
, m_name(IsWinNT ? "" : unicodeToAnsi(name))
|
||||
: m_wname(SystemSupportsUnicode ? name : L"")
|
||||
, m_name (SystemSupportsUnicode ? "" : unicodeToAnsi(name))
|
||||
{
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
FileName::FileName(const wchar_t *name)
|
||||
: m_wname(name)
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
FileName::FileName(const char *name)
|
||||
: m_name(name)
|
||||
{
|
||||
@ -92,7 +79,7 @@ FileName::FileName(const char *name)
|
||||
|
||||
FileName::FileName(const FileName &name)
|
||||
: m_wname(name.m_wname)
|
||||
, m_name(name.m_name)
|
||||
, m_name (name.m_name)
|
||||
{
|
||||
}
|
||||
|
||||
@ -116,7 +103,7 @@ const std::string &FileName::str() const
|
||||
return m_name;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // _WIN32
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// public members
|
||||
|
Loading…
Reference in New Issue
Block a user