# HG changeset patch # User cannam # Date 1245076205 0 # Node ID 1ed95908a39703aaa0ffd8a0ab674cbef8a042d5 # Parent 6c9f10b8a53ab6c16ae2dc19a7a317c306bddf08 * Win32 build fixes for UNICODE. Not yet tested diff -r 6c9f10b8a53a -r 1ed95908a397 examples/ZeroCrossing.cpp --- a/examples/ZeroCrossing.cpp Thu Apr 23 08:59:24 2009 +0000 +++ b/examples/ZeroCrossing.cpp Mon Jun 15 14:30:05 2009 +0000 @@ -181,7 +181,7 @@ Feature feature; feature.hasTimestamp = false; - feature.values.push_back(count); + feature.values.push_back(float(count)); returnFeatures[0].push_back(feature); return returnFeatures; diff -r 6c9f10b8a53a -r 1ed95908a397 src/vamp-hostsdk/PluginLoader.cpp --- a/src/vamp-hostsdk/PluginLoader.cpp Thu Apr 23 08:59:24 2009 +0000 +++ b/src/vamp-hostsdk/PluginLoader.cpp Mon Jun 15 14:30:05 2009 +0000 @@ -513,7 +513,21 @@ { void *handle = 0; #ifdef _WIN32 +#ifdef UNICODE + int len = path.length(); // cannot be more wchars than length in bytes of utf8 string + wchar_t *buffer = new wchar_t[len]; + int rv = MultiByteToWideChar(CP_UTF8, 0, path.c_str(), len, buffer, len); + if (rv <= 0) { + cerr << "Vamp::HostExt::PluginLoader: Unable to convert library path \"" + << path << "\" to wide characters " << endl; + delete[] buffer; + return handle; + } + handle = LoadLibrary(buffer); + delete[] buffer; +#else handle = LoadLibrary(path.c_str()); +#endif if (!handle) { cerr << "Vamp::HostExt::PluginLoader: Unable to load library \"" << path << "\"" << endl; @@ -564,8 +578,41 @@ vector files; #ifdef _WIN32 + string expression = dir + "\\*." + extension; +#ifdef UNICODE + int len = expression.length(); // cannot be more wchars than length in bytes of utf8 string + wchar_t *buffer = new wchar_t[len]; + int rv = MultiByteToWideChar(CP_UTF8, 0, expression.c_str(), len, buffer, len); + if (rv <= 0) { + cerr << "Vamp::HostExt::PluginLoader: Unable to convert wildcard path \"" + << expression << "\" to wide characters" << endl; + delete[] buffer; + return files; + } + WIN32_FIND_DATA data; + HANDLE fh = FindFirstFile(buffer, &data); + if (fh == INVALID_HANDLE_VALUE) { + delete[] buffer; + return files; + } - string expression = dir + "\\*." + extension; + bool ok = true; + while (ok) { + wchar_t *fn = data.cFileName; + int wlen = wcslen(fn); + int maxlen = wlen * 6; + char *conv = new char[maxlen]; + int rv = WideCharToMultiByte(CP_UTF8, 0, fn, wlen, conv, maxlen, 0, 0); + if (rv > 0) { + files.push_back(conv); + } + delete[] conv; + ok = FindNextFile(fh, &data); + } + + FindClose(fh); + delete[] buffer; +#else WIN32_FIND_DATA data; HANDLE fh = FindFirstFile(expression.c_str(), &data); if (fh == INVALID_HANDLE_VALUE) return files; @@ -577,7 +624,7 @@ } FindClose(fh); - +#endif #else size_t extlen = extension.length();