mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-06-13 00:58:29 +02:00
Common: Use fmt where applicable
Begins the transition to using fmt for string formatting where applicable. Given fmt supports formatting std::string instances out of the box, we can remove now-unnecessary calls to .c_str() and .data(). Note that this change does not touch the actual logging subsystem aside from converting the final StringFromFormat call in the process over to fmt::format. Given our logging system is heavily used throughout the entire codebase, and converting that over will be quite a large change by itself, this will be tackled near the end of the conversion process.
This commit is contained in:
@ -9,6 +9,8 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include "Common/CDUtils.h"
|
||||
#include "Common/Common.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
@ -134,20 +136,23 @@ std::vector<std::string> GetCDDevices()
|
||||
}
|
||||
#else
|
||||
// checklist: /dev/cdrom, /dev/dvd /dev/hd?, /dev/scd? /dev/sr?
|
||||
static struct
|
||||
struct CheckListEntry
|
||||
{
|
||||
const char* format;
|
||||
unsigned int num_min;
|
||||
unsigned int num_max;
|
||||
} checklist[] = {
|
||||
};
|
||||
|
||||
constexpr CheckListEntry checklist[] = {
|
||||
#ifdef __linux__
|
||||
{"/dev/cdrom", 0, 0}, {"/dev/dvd", 0, 0}, {"/dev/hd%c", 'a', 'z'},
|
||||
{"/dev/scd%d", 0, 27}, {"/dev/sr%d", 0, 27},
|
||||
{"/dev/cdrom", 0, 0}, {"/dev/dvd", 0, 0}, {"/dev/hd{}", 'a', 'z'},
|
||||
{"/dev/scd{}", 0, 27}, {"/dev/sr{}", 0, 27},
|
||||
#else
|
||||
{"/dev/acd%d", 0, 27},
|
||||
{"/dev/cd%d", 0, 27},
|
||||
{"/dev/acd{}", 0, 27},
|
||||
{"/dev/cd{}", 0, 27},
|
||||
#endif
|
||||
{nullptr, 0, 0}};
|
||||
{nullptr, 0, 0},
|
||||
};
|
||||
|
||||
// Returns true if a device is a block or char device and not a symbolic link
|
||||
static bool IsDevice(const std::string& source_name)
|
||||
@ -189,7 +194,7 @@ std::vector<std::string> GetCDDevices()
|
||||
{
|
||||
for (unsigned int j = checklist[i].num_min; j <= checklist[i].num_max; ++j)
|
||||
{
|
||||
std::string drive = StringFromFormat(checklist[i].format, j);
|
||||
std::string drive = fmt::format(checklist[i].format, j);
|
||||
if (IsCDROM(drive))
|
||||
{
|
||||
drives.push_back(std::move(drive));
|
||||
|
Reference in New Issue
Block a user