From d66b43dadfac1e9324fee48e97361e2f858f8af5 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 21 Jul 2018 15:52:42 -0400 Subject: file_util: Use an enum class for GetUserPath() Instead of using an unsigned int as a parameter and expecting a user to always pass in the correct values, we can just convert the enum into an enum class and use that type as the parameter type instead, which makes the interface more type safe. We also get rid of the bookkeeping "NUM_" element in the enum by just using an unordered map. This function is generally low-frequency in terms of calls (and I'd hope so, considering otherwise would mean we're slamming the disk with IO all the time) so I'd consider this acceptable in this case. --- src/core/telemetry_session.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/core/telemetry_session.cpp') diff --git a/src/core/telemetry_session.cpp b/src/core/telemetry_session.cpp index b9a603df3..69aa7a7be 100644 --- a/src/core/telemetry_session.cpp +++ b/src/core/telemetry_session.cpp @@ -37,7 +37,8 @@ static u64 GenerateTelemetryId() { u64 GetTelemetryId() { u64 telemetry_id{}; - static const std::string& filename{FileUtil::GetUserPath(D_CONFIG_IDX) + "telemetry_id"}; + static const std::string& filename{FileUtil::GetUserPath(FileUtil::UserPath::ConfigDir) + + "telemetry_id"}; if (FileUtil::Exists(filename)) { FileUtil::IOFile file(filename, "rb"); @@ -61,7 +62,8 @@ u64 GetTelemetryId() { u64 RegenerateTelemetryId() { const u64 new_telemetry_id{GenerateTelemetryId()}; - static const std::string& filename{FileUtil::GetUserPath(D_CONFIG_IDX) + "telemetry_id"}; + static const std::string& filename{FileUtil::GetUserPath(FileUtil::UserPath::ConfigDir) + + "telemetry_id"}; FileUtil::IOFile file(filename, "wb"); if (!file.IsOpen()) { -- cgit v1.2.3