diff options
| author | Lioncash <mathew1800@gmail.com> | 2019-06-14 10:53:46 -0400 |
|---|---|---|
| committer | Lioncash <mathew1800@gmail.com> | 2019-06-14 15:04:09 -0400 |
| commit | 5b92d5076a0be89945fa0fc722749dd5fbfcdf4c (patch) | |
| tree | b87080969dd47a01c3a7845d65ef2afdef90928d /Source/Core/Common/CDUtils.cpp | |
| parent | 925afcae3b7b6ea8dde2cfd236288d924c42fa05 (diff) | |
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.
Diffstat (limited to 'Source/Core/Common/CDUtils.cpp')
| -rw-r--r-- | Source/Core/Common/CDUtils.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/Source/Core/Common/CDUtils.cpp b/Source/Core/Common/CDUtils.cpp index 297934ba7c..fb67d076c6 100644 --- a/Source/Core/Common/CDUtils.cpp +++ b/Source/Core/Common/CDUtils.cpp @@ -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)); |
