summaryrefslogtreecommitdiff
path: root/src/core/telemetry_session.cpp
diff options
context:
space:
mode:
authorGravatar Lioncash2018-07-21 15:52:42 -0400
committerGravatar Lioncash2018-07-21 16:21:19 -0400
commitd66b43dadfac1e9324fee48e97361e2f858f8af5 (patch)
tree6007104127ffaa62cb5cb94f5c47fadf4c192fb8 /src/core/telemetry_session.cpp
parentMerge pull request #754 from lioncash/part (diff)
downloadyuzu-d66b43dadfac1e9324fee48e97361e2f858f8af5.tar.gz
yuzu-d66b43dadfac1e9324fee48e97361e2f858f8af5.tar.xz
yuzu-d66b43dadfac1e9324fee48e97361e2f858f8af5.zip
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.
Diffstat (limited to 'src/core/telemetry_session.cpp')
-rw-r--r--src/core/telemetry_session.cpp6
1 files changed, 4 insertions, 2 deletions
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() {
37 37
38u64 GetTelemetryId() { 38u64 GetTelemetryId() {
39 u64 telemetry_id{}; 39 u64 telemetry_id{};
40 static const std::string& filename{FileUtil::GetUserPath(D_CONFIG_IDX) + "telemetry_id"}; 40 static const std::string& filename{FileUtil::GetUserPath(FileUtil::UserPath::ConfigDir) +
41 "telemetry_id"};
41 42
42 if (FileUtil::Exists(filename)) { 43 if (FileUtil::Exists(filename)) {
43 FileUtil::IOFile file(filename, "rb"); 44 FileUtil::IOFile file(filename, "rb");
@@ -61,7 +62,8 @@ u64 GetTelemetryId() {
61 62
62u64 RegenerateTelemetryId() { 63u64 RegenerateTelemetryId() {
63 const u64 new_telemetry_id{GenerateTelemetryId()}; 64 const u64 new_telemetry_id{GenerateTelemetryId()};
64 static const std::string& filename{FileUtil::GetUserPath(D_CONFIG_IDX) + "telemetry_id"}; 65 static const std::string& filename{FileUtil::GetUserPath(FileUtil::UserPath::ConfigDir) +
66 "telemetry_id"};
65 67
66 FileUtil::IOFile file(filename, "wb"); 68 FileUtil::IOFile file(filename, "wb");
67 if (!file.IsOpen()) { 69 if (!file.IsOpen()) {