diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/crypto/key_manager.cpp | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/core/crypto/key_manager.cpp b/src/core/crypto/key_manager.cpp index 222fc95ba..12f13b742 100644 --- a/src/core/crypto/key_manager.cpp +++ b/src/core/crypto/key_manager.cpp | |||
| @@ -668,23 +668,27 @@ void KeyManager::WriteKeyToFile(KeyCategory category, std::string_view keyname, | |||
| 668 | const std::array<u8, Size>& key) { | 668 | const std::array<u8, Size>& key) { |
| 669 | const std::string yuzu_keys_dir = FileUtil::GetUserPath(FileUtil::UserPath::KeysDir); | 669 | const std::string yuzu_keys_dir = FileUtil::GetUserPath(FileUtil::UserPath::KeysDir); |
| 670 | std::string filename = "title.keys_autogenerated"; | 670 | std::string filename = "title.keys_autogenerated"; |
| 671 | if (category == KeyCategory::Standard) | 671 | if (category == KeyCategory::Standard) { |
| 672 | filename = dev_mode ? "dev.keys_autogenerated" : "prod.keys_autogenerated"; | 672 | filename = dev_mode ? "dev.keys_autogenerated" : "prod.keys_autogenerated"; |
| 673 | else if (category == KeyCategory::Console) | 673 | } else if (category == KeyCategory::Console) { |
| 674 | filename = "console.keys_autogenerated"; | 674 | filename = "console.keys_autogenerated"; |
| 675 | const auto add_info_text = !FileUtil::Exists(yuzu_keys_dir + DIR_SEP + filename); | 675 | } |
| 676 | FileUtil::CreateFullPath(yuzu_keys_dir + DIR_SEP + filename); | 676 | |
| 677 | std::ofstream file(yuzu_keys_dir + DIR_SEP + filename, std::ios::app); | 677 | const auto path = yuzu_keys_dir + DIR_SEP + filename; |
| 678 | if (!file.is_open()) | 678 | const auto add_info_text = !FileUtil::Exists(path); |
| 679 | FileUtil::CreateFullPath(path); | ||
| 680 | FileUtil::IOFile file{path, "a"}; | ||
| 681 | if (!file.IsOpen()) { | ||
| 679 | return; | 682 | return; |
| 683 | } | ||
| 680 | if (add_info_text) { | 684 | if (add_info_text) { |
| 681 | file | 685 | file.WriteString( |
| 682 | << "# This file is autogenerated by Yuzu\n" | 686 | "# This file is autogenerated by Yuzu\n" |
| 683 | << "# It serves to store keys that were automatically generated from the normal keys\n" | 687 | "# It serves to store keys that were automatically generated from the normal keys\n" |
| 684 | << "# If you are experiencing issues involving keys, it may help to delete this file\n"; | 688 | "# If you are experiencing issues involving keys, it may help to delete this file\n"); |
| 685 | } | 689 | } |
| 686 | 690 | ||
| 687 | file << fmt::format("\n{} = {}", keyname, Common::HexToString(key)); | 691 | file.WriteString(fmt::format("\n{} = {}", keyname, Common::HexToString(key))); |
| 688 | AttemptLoadKeyFile(yuzu_keys_dir, yuzu_keys_dir, filename, category == KeyCategory::Title); | 692 | AttemptLoadKeyFile(yuzu_keys_dir, yuzu_keys_dir, filename, category == KeyCategory::Title); |
| 689 | } | 693 | } |
| 690 | 694 | ||