From 1aa2b99a982e83022c9aae23c6a47eae119d21a4 Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Thu, 27 Dec 2018 20:54:44 -0500 Subject: mii: Implement Delete and Destroy file --- src/core/hle/service/mii/mii_manager.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/core/hle/service/mii/mii_manager.cpp') diff --git a/src/core/hle/service/mii/mii_manager.cpp b/src/core/hle/service/mii/mii_manager.cpp index 7011ea2bd..04fc2180b 100644 --- a/src/core/hle/service/mii/mii_manager.cpp +++ b/src/core/hle/service/mii/mii_manager.cpp @@ -32,6 +32,13 @@ constexpr MiiStoreData DEFAULT_MII = { // Default values taken from multiple real databases const MiiDatabase DEFAULT_MII_DATABASE{Common::MakeMagic('N', 'F', 'D', 'B'), {}, {1}, 0, 0}; +constexpr std::array SOURCE_NAMES{ + "Database", + "Default", + "Account", + "Friend", +}; + template std::array ResizeArray(const std::array& in) { std::array out{}; @@ -167,6 +174,11 @@ MiiStoreData ConvertInfoToStoreData(const MiiInfo& info) { } // namespace +std::ostream& operator<<(std::ostream& os,Source source) { + os << SOURCE_NAMES.at(static_cast(source)); + return os; +} + std::u16string MiiInfo::Name() const { return Common::UTF16StringFromFixedZeroTerminatedBuffer(name.data(), name.size()); } @@ -212,6 +224,10 @@ void MiiManager::ResetUpdatedFlag() { updated_flag = false; } +bool MiiManager::IsTestModeEnabled() const { + return is_test_mode_enabled; +} + bool MiiManager::Empty() const { return Size() == 0; } @@ -318,6 +334,17 @@ bool MiiManager::AddOrReplace(const MiiStoreData& data) { return true; } +bool MiiManager::DestroyFile() { + database = DEFAULT_MII_DATABASE; + updated_flag = false; + return DeleteFile(); +} + +bool MiiManager::DeleteFile() { + const auto path = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir) + MII_SAVE_DATABASE_PATH; + return FileUtil::Exists(path) && FileUtil::Delete(path); +} + void MiiManager::WriteToFile() { const auto raw_path = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir) + "/system/save/8000000000000030"; -- cgit v1.2.3