2015-03-01 00:48:44 +01:00
|
|
|
/*
|
2017-01-03 20:48:59 +01:00
|
|
|
* Copyright 2003-2017 The Music Player Daemon Project
|
2015-03-01 00:48:44 +01:00
|
|
|
* http://www.musicpd.org
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "TagArchive.hxx"
|
|
|
|
#include "TagStream.hxx"
|
2016-02-26 14:46:01 +01:00
|
|
|
#include "archive/ArchiveFile.hxx"
|
2015-03-01 00:48:44 +01:00
|
|
|
#include "input/InputStream.hxx"
|
|
|
|
|
|
|
|
bool
|
2016-02-26 15:07:30 +01:00
|
|
|
tag_archive_scan(ArchiveFile &archive, const char *path_utf8,
|
2018-01-21 11:41:13 +01:00
|
|
|
const TagHandler &handler, void *handler_ctx) noexcept
|
2016-09-09 15:37:06 +02:00
|
|
|
try {
|
2015-03-01 00:48:44 +01:00
|
|
|
Mutex mutex;
|
2016-02-26 15:07:30 +01:00
|
|
|
|
2018-06-22 19:37:18 +02:00
|
|
|
auto is = archive.OpenStream(path_utf8, mutex);
|
2016-02-26 13:21:27 +01:00
|
|
|
if (!is)
|
2015-03-01 00:48:44 +01:00
|
|
|
return false;
|
|
|
|
|
2016-02-26 13:21:27 +01:00
|
|
|
return tag_stream_scan(*is, handler, handler_ctx);
|
2016-09-09 15:37:06 +02:00
|
|
|
} catch (const std::exception &e) {
|
|
|
|
return false;
|
2015-03-01 00:48:44 +01:00
|
|
|
}
|
2016-02-26 13:20:30 +01:00
|
|
|
|
2016-02-26 14:46:01 +01:00
|
|
|
bool
|
|
|
|
tag_archive_scan(ArchiveFile &archive, const char *path_utf8,
|
2018-01-21 11:41:13 +01:00
|
|
|
TagBuilder &builder) noexcept
|
2016-09-09 15:37:06 +02:00
|
|
|
try {
|
2016-02-26 14:46:01 +01:00
|
|
|
Mutex mutex;
|
|
|
|
|
2018-06-22 19:37:18 +02:00
|
|
|
auto is = archive.OpenStream(path_utf8, mutex);
|
2016-02-26 14:46:01 +01:00
|
|
|
return is && tag_stream_scan(*is, builder);
|
2016-09-09 15:37:06 +02:00
|
|
|
} catch (const std::exception &e) {
|
|
|
|
return false;
|
2016-02-26 14:46:01 +01:00
|
|
|
}
|