use more libfmt instead of sprintf()
This commit is contained in:
@@ -12,14 +12,16 @@
|
||||
#include "fs/AllocatedPath.hxx"
|
||||
#include "fs/FileSystem.hxx"
|
||||
#include "fs/NarrowPath.hxx"
|
||||
#include "lib/fmt/PathFormatter.hxx"
|
||||
#include "util/ScopeExit.hxx"
|
||||
#include "util/StringCompare.hxx"
|
||||
#include "util/StringFormat.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
#include "Log.hxx"
|
||||
|
||||
#include <gme/gme.h>
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include <stdlib.h>
|
||||
@@ -228,16 +230,16 @@ ScanGmeInfo(const gme_info_t &info, unsigned song_num, int track_count,
|
||||
));
|
||||
|
||||
if (track_count > 1)
|
||||
handler.OnTag(TAG_TRACK, StringFormat<16>("%u", song_num + 1).c_str());
|
||||
handler.OnTag(TAG_TRACK, fmt::format_int{song_num + 1}.c_str());
|
||||
|
||||
if (!StringIsEmpty(info.song)) {
|
||||
if (track_count > 1) {
|
||||
/* start numbering subtunes from 1 */
|
||||
const auto tag_title =
|
||||
StringFormat<1024>("%s (%u/%d)",
|
||||
info.song, song_num + 1,
|
||||
track_count);
|
||||
handler.OnTag(TAG_TITLE, tag_title.c_str());
|
||||
fmt::format("{} ({}/{})",
|
||||
info.song, song_num + 1,
|
||||
track_count);
|
||||
handler.OnTag(TAG_TITLE, tag_title);
|
||||
} else
|
||||
handler.OnTag(TAG_TITLE, info.song);
|
||||
}
|
||||
@@ -306,7 +308,7 @@ gme_container_scan(Path path_fs)
|
||||
if (num_songs < 2)
|
||||
return list;
|
||||
|
||||
const auto *subtune_suffix = path_fs.GetExtension();
|
||||
const Path subtune_suffix = Path::FromFS(path_fs.GetExtension());
|
||||
|
||||
TagBuilder tag_builder;
|
||||
|
||||
@@ -315,10 +317,9 @@ gme_container_scan(Path path_fs)
|
||||
AddTagHandler h(tag_builder);
|
||||
ScanMusicEmu(emu, i, h);
|
||||
|
||||
const auto track_name =
|
||||
StringFormat<64>(SUBTUNE_PREFIX "%03u.%s", i+1,
|
||||
subtune_suffix);
|
||||
tail = list.emplace_after(tail, track_name,
|
||||
auto track_name = fmt::format(SUBTUNE_PREFIX "{:03}.{}",
|
||||
i + 1, subtune_suffix);
|
||||
tail = list.emplace_after(tail, std::move(track_name),
|
||||
tag_builder.Commit());
|
||||
}
|
||||
|
||||
|
@@ -15,7 +15,6 @@
|
||||
#ifdef HAVE_SIDPLAYFP
|
||||
#include "io/FileReader.hxx"
|
||||
#endif
|
||||
#include "util/StringFormat.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
#include "util/AllocatedString.hxx"
|
||||
#include "util/CharUtil.hxx"
|
||||
@@ -38,6 +37,8 @@
|
||||
#include <sidplay/utils/SidDatabase.h>
|
||||
#endif
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include <iterator>
|
||||
#include <memory>
|
||||
|
||||
@@ -510,8 +511,8 @@ ScanSidTuneInfo(const SidTuneInfo &info, unsigned track, unsigned n_tracks,
|
||||
|
||||
if (n_tracks > 1) {
|
||||
const auto tag_title =
|
||||
StringFormat<1024>("%s (%u/%u)",
|
||||
album.c_str(), track, n_tracks);
|
||||
fmt::format("{} ({}/{})",
|
||||
album.c_str(), track, n_tracks);
|
||||
handler.OnTag(TAG_TITLE, tag_title.c_str());
|
||||
} else
|
||||
handler.OnTag(TAG_TITLE, album.c_str());
|
||||
@@ -532,7 +533,7 @@ ScanSidTuneInfo(const SidTuneInfo &info, unsigned track, unsigned n_tracks,
|
||||
handler.OnTag(TAG_DATE, date.c_str());
|
||||
|
||||
/* track */
|
||||
handler.OnTag(TAG_TRACK, StringFormat<16>("%u", track).c_str());
|
||||
handler.OnTag(TAG_TRACK, fmt::format_int{track}.c_str());
|
||||
}
|
||||
|
||||
static bool
|
||||
@@ -611,7 +612,7 @@ sidplay_container_scan(Path path_fs)
|
||||
/* Construct container/tune path names, eg.
|
||||
Delta.sid/tune_001.sid */
|
||||
tail = list.emplace_after(tail,
|
||||
StringFormat<32>(SUBTUNE_PREFIX "%03u.sid", i),
|
||||
fmt::format(SUBTUNE_PREFIX "{:03}.sid", i),
|
||||
tag_builder.Commit());
|
||||
}
|
||||
|
||||
|
@@ -5,11 +5,12 @@
|
||||
#include "../DecoderAPI.hxx"
|
||||
#include "tag/Handler.hxx"
|
||||
#include "util/ScopeExit.hxx"
|
||||
#include "util/StringFormat.hxx"
|
||||
#include "fs/AllocatedPath.hxx"
|
||||
#include "fs/FileSystem.hxx"
|
||||
#include "fs/Path.hxx"
|
||||
#include "fs/NarrowPath.hxx"
|
||||
#include "lib/fmt/ToBuffer.hxx"
|
||||
#include "lib/fmt/PathFormatter.hxx"
|
||||
#include "PluginUnavailable.hxx"
|
||||
|
||||
#ifdef _WIN32
|
||||
@@ -31,11 +32,9 @@ wildmidi_init(const ConfigBlock &block)
|
||||
block.GetPath("config_file",
|
||||
"/etc/timidity/timidity.cfg");
|
||||
|
||||
if (!FileExists(path)) {
|
||||
const auto utf8 = path.ToUTF8();
|
||||
throw PluginUnavailable(StringFormat<1024>("configuration file does not exist: %s",
|
||||
utf8.c_str()));
|
||||
}
|
||||
if (!FileExists(path))
|
||||
throw PluginUnavailable{FmtBuffer<1024>("configuration file does not exist: {}",
|
||||
path)};
|
||||
|
||||
#ifdef LIBWILDMIDI_VERSION
|
||||
/* WildMidi_ClearError() requires libwildmidi 0.4 */
|
||||
|
Reference in New Issue
Block a user