comparison src/vamp-hostsdk/PluginLoader.cpp @ 331:9648ba9812d6

Apply vamp-2.3-windows-unicode.patch from RJ Ryan in #464
author Chris Cannam
date Thu, 24 May 2012 16:38:09 +0100
parents 0e08ebd5c13b
children 06988ce35ff0
comparison
equal deleted inserted replaced
330:dba435f9b283 331:9648ba9812d6
529 PluginLoader::Impl::loadLibrary(string path) 529 PluginLoader::Impl::loadLibrary(string path)
530 { 530 {
531 void *handle = 0; 531 void *handle = 0;
532 #ifdef _WIN32 532 #ifdef _WIN32
533 #ifdef UNICODE 533 #ifdef UNICODE
534 int len = path.length(); // cannot be more wchars than length in bytes of utf8 string 534 int len = path.length() + 1; // cannot be more wchars than length in bytes of utf8 string
535 wchar_t *buffer = new wchar_t[len]; 535 wchar_t *buffer = new wchar_t[len];
536 int rv = MultiByteToWideChar(CP_UTF8, 0, path.c_str(), len, buffer, len); 536 int rv = MultiByteToWideChar(CP_UTF8, 0, path.c_str(), len, buffer, len);
537 if (rv <= 0) { 537 if (rv <= 0) {
538 cerr << "Vamp::HostExt::PluginLoader: Unable to convert library path \"" 538 cerr << "Vamp::HostExt::PluginLoader: Unable to convert library path \""
539 << path << "\" to wide characters " << endl; 539 << path << "\" to wide characters " << endl;
595 vector<string> files; 595 vector<string> files;
596 596
597 #ifdef _WIN32 597 #ifdef _WIN32
598 string expression = dir + "\\*." + extension; 598 string expression = dir + "\\*." + extension;
599 #ifdef UNICODE 599 #ifdef UNICODE
600 int len = expression.length(); // cannot be more wchars than length in bytes of utf8 string 600 int len = expression.length() + 1; // cannot be more wchars than length in bytes of utf8 string
601 wchar_t *buffer = new wchar_t[len]; 601 wchar_t *buffer = new wchar_t[len];
602 int rv = MultiByteToWideChar(CP_UTF8, 0, expression.c_str(), len, buffer, len); 602 int rv = MultiByteToWideChar(CP_UTF8, 0, expression.c_str(), len, buffer, len);
603 if (rv <= 0) { 603 if (rv <= 0) {
604 cerr << "Vamp::HostExt::PluginLoader: Unable to convert wildcard path \"" 604 cerr << "Vamp::HostExt::PluginLoader: Unable to convert wildcard path \""
605 << expression << "\" to wide characters" << endl; 605 << expression << "\" to wide characters" << endl;
614 } 614 }
615 615
616 bool ok = true; 616 bool ok = true;
617 while (ok) { 617 while (ok) {
618 wchar_t *fn = data.cFileName; 618 wchar_t *fn = data.cFileName;
619 int wlen = wcslen(fn); 619 int wlen = wcslen(fn) + 1;
620 int maxlen = wlen * 6; 620 int maxlen = wlen * 6;
621 char *conv = new char[maxlen]; 621 char *conv = new char[maxlen];
622 int rv = WideCharToMultiByte(CP_UTF8, 0, fn, wlen, conv, maxlen, 0, 0); 622 int rv = WideCharToMultiByte(CP_UTF8, 0, fn, wlen, conv, maxlen, 0, 0);
623 if (rv > 0) { 623 if (rv > 0) {
624 files.push_back(conv); 624 files.push_back(conv);