This commit is contained in:
OpenSauce 2025-10-05 15:10:22 -04:00 committed by GitHub
commit 5b6d1ced74
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 16 additions and 10 deletions

View file

@ -874,7 +874,6 @@ void SetUserPath(const std::string& path) {
g_paths.emplace(UserPath::LoadDir, user_path + LOAD_DIR DIR_SEP);
g_paths.emplace(UserPath::StatesDir, user_path + STATES_DIR DIR_SEP);
g_paths.emplace(UserPath::IconsDir, user_path + ICONS_DIR DIR_SEP);
g_paths.emplace(UserPath::PlayTimeDir, user_path + LOG_DIR DIR_SEP);
g_default_paths = g_paths;
}

View file

@ -51,7 +51,6 @@ enum class UserPath {
LoadDir,
LogDir,
NANDDir,
PlayTimeDir,
RootDir,
SDMCDir,
ShaderDir,

View file

@ -20,19 +20,27 @@ struct PlayTimeElement {
PlayTime play_time;
};
#define PLAY_TIME_FILENAME "play_time.bin"
std::string GetCurrentUserPlayTimePath() {
return FileUtil::GetUserPath(FileUtil::UserPath::PlayTimeDir) + DIR_SEP + "play_time.bin";
return FileUtil::GetUserPath(FileUtil::UserPath::SysDataDir) + DIR_SEP + PLAY_TIME_FILENAME;
}
[[nodiscard]] bool ReadPlayTimeFile(PlayTimeDatabase& out_play_time_db) {
const auto filename = GetCurrentUserPlayTimePath();
const auto filepath = GetCurrentUserPlayTimePath();
const auto old_filepath =
FileUtil::GetUserPath(FileUtil::UserPath::LogDir) + DIR_SEP + PLAY_TIME_FILENAME;
if (FileUtil::Exists(old_filepath) && !FileUtil::Exists(filepath)) {
static_cast<void>(FileUtil::Rename(old_filepath, filepath));
}
out_play_time_db.clear();
if (FileUtil::Exists(filename)) {
FileUtil::IOFile file{filename, "rb"};
if (FileUtil::Exists(filepath)) {
FileUtil::IOFile file{filepath, "rb"};
if (!file.IsOpen()) {
LOG_ERROR(Frontend, "Failed to open play time file: {}", filename);
LOG_ERROR(Frontend, "Failed to open play time file: {}", filepath);
return false;
}
@ -54,11 +62,11 @@ std::string GetCurrentUserPlayTimePath() {
}
[[nodiscard]] bool WritePlayTimeFile(const PlayTimeDatabase& play_time_db) {
const auto filename = GetCurrentUserPlayTimePath();
const auto filepath = GetCurrentUserPlayTimePath();
FileUtil::IOFile file{filename, "wb"};
FileUtil::IOFile file{filepath, "wb"};
if (!file.IsOpen()) {
LOG_ERROR(Frontend, "Failed to open play time file: {}", filename);
LOG_ERROR(Frontend, "Failed to open play time file: {}", filepath);
return false;
}