]> granicus.if.org Git - taglib/commitdiff
Fix an error message in Win32
authorTsuda kageyu <tsuda.kageyu@gmail.com>
Thu, 18 Apr 2013 21:13:27 +0000 (06:13 +0900)
committerTsuda kageyu <tsuda.kageyu@gmail.com>
Thu, 18 Apr 2013 21:13:27 +0000 (06:13 +0900)
taglib/CMakeLists.txt
taglib/fileref.cpp
taglib/fileref.h
taglib/toolkit/tfilestream.cpp

index 63b88bb7695b701046ce5253dff7b63860054162..a940caf5def3d2d4a726bfb897b6e0fb68db22ec 100644 (file)
@@ -311,10 +311,6 @@ if(ZLIB_FOUND)
        target_link_libraries(tag ${ZLIB_LIBRARIES})
 endif()
 
-if(WIN32 AND NOT TAGLIB_STATIC)
-       target_link_libraries(tag shlwapi.lib)
-endif()
-
 set_target_properties(tag PROPERTIES
   VERSION ${TAGLIB_SOVERSION_MAJOR}.${TAGLIB_SOVERSION_MINOR}.${TAGLIB_SOVERSION_PATCH}
   SOVERSION ${TAGLIB_SOVERSION_MAJOR}
index a6c96c0798e82f644340fd401908f00eb25dc1d7..46e59ff16bc1311e177afd276ddfdeaf7efcb6db 100644 (file)
@@ -35,7 +35,6 @@
 # include <Shlwapi.h>
 #endif 
 
-
 #include <tfile.h>
 #include <tstring.h>
 #include <tdebug.h>
index 0f0c21a4dc77f917f9d5cd10657fcb80c9f05ffe..95a7506da053d89aa279efcc43138ebbd3885d37 100644 (file)
 #include "taglib_export.h"
 #include "audioproperties.h"
 
+#if _WIN32
+# pragma comment(lib, "shlwapi.lib")
+#endif
+
 namespace TagLib {
 
   class Tag;
index 5b7676b2e9d930e1692482ea5a0d2676242f4940..c008c190ace4614758037f54d0535fa464c18b8e 100644 (file)
@@ -82,6 +82,36 @@ namespace {
       return 0;
   }
 
+# if _DEBUG
+
+  // Convert a string in a local encoding into a UTF-16 string.
+
+  // This function should only be used to generate an error message.
+  // In actual use, file names in local encodings are passed to CreateFileA()
+  // without any conversions.
+
+  String fileNameToString(const FileName &name)
+  {
+    if(!name.wstr().empty()) {
+      return String(name.wstr());
+    } 
+    else if(!name.str().empty()) {
+      const int len = MultiByteToWideChar(CP_ACP, 0, name.str().c_str(), -1, NULL, 0);
+      if(len == 0)
+        return String::null;
+
+      wstring wstr(len, L'\0');
+      MultiByteToWideChar(CP_ACP, 0, name.str().c_str(), -1, &wstr[0], len);
+
+      return String(wstr);
+    }
+    else {
+      return String::null;
+    }
+  }
+
+# endif
+
 #else
 
   // For non-Windows 
@@ -144,12 +174,7 @@ FileStream::FileStreamPrivate::FileStreamPrivate(const FileName &fileName, bool
   {
 # ifdef _WIN32
 
-    if(!name.wstr().empty()) {
-      debug("Could not open file " + String(name.wstr()));
-    }
-    else {
-      debug("Could not open file " + String(name.str()));
-    }
+    debug("Could not open file " + fileNameToString(name));
 
 # else