diff options
author | Max Kellermann <max@musicpd.org> | 2016-11-22 09:33:52 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2016-11-22 09:33:52 +0100 |
commit | 0abee77e62636cceec966bda77696b16ab1ed96b (patch) | |
tree | 271561c3e9a3b8f03612a2831aa65fe090ae65a4 /src/decoder/plugins/SidplayDecoderPlugin.cxx | |
parent | 114fcee2ae897bd5dd740cb04a3f12b7ae60cb3f (diff) |
decoder/DecoderPlugin: container_scan() returns forward_list<string>
Diffstat (limited to 'src/decoder/plugins/SidplayDecoderPlugin.cxx')
-rw-r--r-- | src/decoder/plugins/SidplayDecoderPlugin.cxx | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/src/decoder/plugins/SidplayDecoderPlugin.cxx b/src/decoder/plugins/SidplayDecoderPlugin.cxx index b3b122ac3..42a4d595f 100644 --- a/src/decoder/plugins/SidplayDecoderPlugin.cxx +++ b/src/decoder/plugins/SidplayDecoderPlugin.cxx @@ -25,14 +25,11 @@ #include "fs/AllocatedPath.hxx" #include "util/Macros.hxx" #include "util/FormatString.hxx" -#include "util/AllocatedString.hxx" #include "util/Domain.hxx" #include "system/ByteOrder.hxx" #include "system/FatalError.hxx" #include "Log.hxx" -#include <string.h> - #ifdef HAVE_SIDPLAYFP #include <sidplayfp/sidplayfp.h> #include <sidplayfp/SidInfo.h> @@ -49,6 +46,9 @@ #include <sidplay/utils/SidDatabase.h> #endif +#include <string.h> +#include <stdio.h> + #define SUBTUNE_PREFIX "tune_" static constexpr Domain sidplay_domain("sidplay"); @@ -476,12 +476,14 @@ sidplay_scan_file(Path path_fs, return true; } -static AllocatedString<> -sidplay_container_scan(Path path_fs, const unsigned int tnum) +static std::forward_list<std::string> +sidplay_container_scan(Path path_fs) { + std::forward_list<std::string> list; + SidTune tune(path_fs.c_str(), nullptr, true); if (!tune.getStatus()) - return nullptr; + return list; #ifdef HAVE_SIDPLAYFP const SidTuneInfo &info = *tune.getInfo(); @@ -494,14 +496,18 @@ sidplay_container_scan(Path path_fs, const unsigned int tnum) /* Don't treat sids containing a single tune as containers */ if(!all_files_are_containers && n_tracks < 2) - return nullptr; + return list; + + auto tail = list.before_begin(); + for (unsigned i = 1; i < n_tracks; ++i) { + char track_name[32]; + /* Construct container/tune path names, eg. + Delta.sid/tune_001.sid */ + sprintf(track_name, SUBTUNE_PREFIX "%03u.sid", i); + tail = list.emplace_after(tail, track_name); + } - /* Construct container/tune path names, eg. - Delta.sid/tune_001.sid */ - if (tnum <= n_tracks) { - return FormatString(SUBTUNE_PREFIX "%03u.sid", tnum); - } else - return nullptr; + return list; } static const char *const sidplay_suffixes[] = { |