/thirdparty/liblastfm2/src/types/Mbid.cpp

http://github.com/tomahawk-player/tomahawk · C++ · 36 lines · 16 code · 1 blank · 19 comment · 2 complexity · dc4d8eeb6b4d3b934ea80796b3087eb8 MD5 · raw file

  1. /*
  2. Copyright 2009 Last.fm Ltd.
  3. - Primarily authored by Max Howell, Jono Cole and Doug Mansell
  4. This file is part of liblastfm.
  5. liblastfm is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. liblastfm is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with liblastfm. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include "Mbid.h"
  17. #include "mbid_mp3.c"
  18. #include <QFile>
  19. namespace lastfm
  20. {
  21. Mbid //static
  22. Mbid::fromLocalFile( const QString& path )
  23. {
  24. char out[MBID_BUFFER_SIZE];
  25. QByteArray const bytes = QFile::encodeName( path );
  26. int const r = getMP3_MBID( bytes.data(), out );
  27. Mbid mbid;
  28. if (r == 0) mbid.id = QString::fromLatin1( out );
  29. return mbid;
  30. }
  31. }