set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
-if(WIN32 AND NOT MSVC)
- find_package(SHLWAPI)
- if(SHLWAPI_FOUND)
- set(HAVE_SHLWAPI 1)
- else()
- set(HAVE_SHLWAPI 0)
- endif()
-endif()
-
find_package(CppUnit)
if(NOT CppUnit_FOUND AND BUILD_TESTS)
message(STATUS "CppUnit not found, disabling tests.")
+++ /dev/null
-# *\r
-# * It is what it is, you can do with it as you please.\r
-# *\r
-# * Just don't blame me if it teaches your computer to smoke!\r
-# *\r
-# * -Enjoy\r
-# * fh :)_~\r
-# *\r
-FIND_PATH(SHLWAPI_INCLUDE_DIR shlwapi.h)\r
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(SHLWAPI REQUIRED_VARS SHLWAPI_LIBRARY SHLWAPI_INCLUDE_DIR)\r
-IF(SHLWAPI_FOUND)\r
- SET(SHLWAPI_LIBRARIES ${SHLWAPI_LIBRARY} )\r
-ENDIF(SHLWAPI_FOUND)\r
-\r
include_directories(${ZLIB_INCLUDE_DIR})
endif()
-if(NOT MSVC AND SHLWAPI_FOUND)
- include_directories(${SHLWAPI_INCLUDE_DIR})
-endif()
-
set(tag_HDRS
tag.h
fileref.h
target_link_libraries(tag ${ZLIB_LIBRARIES})
endif()
-if(MSVC)
- target_link_libraries(tag shlwapi.lib)
-else()
- if(SHLWAPI_FOUND)
- target_link_libraries(tag ${SHLWAPI_LIBRARIES})
- endif()
-endif()
-
set_target_properties(tag PROPERTIES
VERSION ${TAGLIB_SOVERSION_MAJOR}.${TAGLIB_SOVERSION_MINOR}.${TAGLIB_SOVERSION_PATCH}
SOVERSION ${TAGLIB_SOVERSION_MAJOR}
#include "taglib_config.h"
-#ifdef _WIN32
-# include <Shlwapi.h>
-#endif
-
#include <tfile.h>
#include <tstring.h>
#include <tdebug.h>
// Ok, this is really dumb for now, but it works for testing.
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();
- }
+ String s = fileName.toString();
+
#else
- {
+
String s = fileName;
+
+ #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
return 0;
}
-# ifndef NDEBUG
-
- // Convert a string in a local encoding into a UTF-16 string.
-
- // Debugging use only. 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 // _WIN32
struct FileNameHandle : public std::string
if(d->file == InvalidFileHandle)
{
# ifdef _WIN32
- debug("Could not open file " + fileNameToString(fileName));
+ debug("Could not open file " + fileName.toString());
# else
debug("Could not open file " + String(static_cast<const char *>(d->name)));
# endif
return d->name;
}
+String FileName::toString() const
+{
+ if(!d->wname.empty()) {
+ return String(d->wname);
+ }
+ else if(!d->name.empty()) {
+ const int len = MultiByteToWideChar(CP_ACP, 0, d->name.c_str(), -1, NULL, 0);
+ if(len == 0)
+ return String::null;
+
+ std::vector<wchar_t> buf(len);
+ MultiByteToWideChar(CP_ACP, 0, d->name.c_str(), -1, &buf[0], len);
+
+ return String(&buf[0]);
+ }
+ else {
+ return String::null;
+ }
+}
+
+
#endif // _WIN32
////////////////////////////////////////////////////////////////////////////////
const std::wstring &wstr() const;
const std::string &str() const;
+ String toString() const;
+
private:
class FileNamePrivate;
FileNamePrivate *d;