diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/yuzu/game_list_worker.cpp | 52 |
1 files changed, 24 insertions, 28 deletions
diff --git a/src/yuzu/game_list_worker.cpp b/src/yuzu/game_list_worker.cpp index 1ccabed59..4f30e9147 100644 --- a/src/yuzu/game_list_worker.cpp +++ b/src/yuzu/game_list_worker.cpp | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | #include <vector> | 8 | #include <vector> |
| 9 | 9 | ||
| 10 | #include <QDir> | 10 | #include <QDir> |
| 11 | #include <QFile> | ||
| 11 | #include <QFileInfo> | 12 | #include <QFileInfo> |
| 12 | #include <QSettings> | 13 | #include <QSettings> |
| 13 | 14 | ||
| @@ -46,20 +47,17 @@ QString GetGameListCachedObject(const std::string& filename, const std::string& | |||
| 46 | if (!FileUtil::Exists(path)) { | 47 | if (!FileUtil::Exists(path)) { |
| 47 | const auto str = generator(); | 48 | const auto str = generator(); |
| 48 | 49 | ||
| 49 | std::ofstream stream(path); | 50 | QFile file{QString::fromStdString(path)}; |
| 50 | if (stream) { | 51 | if (file.open(QFile::WriteOnly)) { |
| 51 | stream << str.toStdString(); | 52 | file.write(str.toUtf8()); |
| 52 | } | 53 | } |
| 53 | 54 | ||
| 54 | return str; | 55 | return str; |
| 55 | } | 56 | } |
| 56 | 57 | ||
| 57 | std::ifstream stream(path); | 58 | QFile file{QString::fromStdString(path)}; |
| 58 | 59 | if (file.open(QFile::ReadOnly)) { | |
| 59 | if (stream) { | 60 | return QString::fromUtf8(file.readAll()); |
| 60 | const std::string out(std::istreambuf_iterator<char>{stream}, | ||
| 61 | std::istreambuf_iterator<char>{}); | ||
| 62 | return QString::fromStdString(out); | ||
| 63 | } | 61 | } |
| 64 | 62 | ||
| 65 | return generator(); | 63 | return generator(); |
| @@ -82,53 +80,51 @@ std::pair<std::vector<u8>, std::string> GetGameListCachedObject( | |||
| 82 | if (!FileUtil::Exists(path1) || !FileUtil::Exists(path2)) { | 80 | if (!FileUtil::Exists(path1) || !FileUtil::Exists(path2)) { |
| 83 | const auto [icon, nacp] = generator(); | 81 | const auto [icon, nacp] = generator(); |
| 84 | 82 | ||
| 85 | FileUtil::IOFile file1(path1, "wb"); | 83 | QFile file1{QString::fromStdString(path1)}; |
| 86 | if (!file1.IsOpen()) { | 84 | if (!file1.open(QFile::WriteOnly)) { |
| 87 | LOG_ERROR(Frontend, "Failed to open cache file."); | 85 | LOG_ERROR(Frontend, "Failed to open cache file."); |
| 88 | return generator(); | 86 | return generator(); |
| 89 | } | 87 | } |
| 90 | 88 | ||
| 91 | if (!file1.Resize(icon.size())) { | 89 | if (!file1.resize(icon.size())) { |
| 92 | LOG_ERROR(Frontend, "Failed to resize cache file to necessary size."); | 90 | LOG_ERROR(Frontend, "Failed to resize cache file to necessary size."); |
| 93 | return generator(); | 91 | return generator(); |
| 94 | } | 92 | } |
| 95 | 93 | ||
| 96 | if (file1.WriteBytes(icon.data(), icon.size()) != icon.size()) { | 94 | if (file1.write(reinterpret_cast<const char*>(icon.data()), icon.size()) != icon.size()) { |
| 97 | LOG_ERROR(Frontend, "Failed to write data to cache file."); | 95 | LOG_ERROR(Frontend, "Failed to write data to cache file."); |
| 98 | return generator(); | 96 | return generator(); |
| 99 | } | 97 | } |
| 100 | 98 | ||
| 101 | std::ofstream stream2(path2, std::ios::out); | 99 | QFile file2{QString::fromStdString(path2)}; |
| 102 | if (stream2) { | 100 | if (file2.open(QFile::WriteOnly)) { |
| 103 | stream2 << nacp; | 101 | file2.write(nacp.data(), nacp.size()); |
| 104 | } | 102 | } |
| 105 | 103 | ||
| 106 | return std::make_pair(icon, nacp); | 104 | return std::make_pair(icon, nacp); |
| 107 | } | 105 | } |
| 108 | 106 | ||
| 109 | FileUtil::IOFile file1(path1, "rb"); | 107 | QFile file1(QString::fromStdString(path1)); |
| 110 | std::ifstream stream2(path2); | 108 | QFile file2(QString::fromStdString(path2)); |
| 111 | 109 | ||
| 112 | if (!file1.IsOpen()) { | 110 | if (!file1.open(QFile::ReadOnly)) { |
| 113 | LOG_ERROR(Frontend, "Failed to open cache file for reading."); | 111 | LOG_ERROR(Frontend, "Failed to open cache file for reading."); |
| 114 | return generator(); | 112 | return generator(); |
| 115 | } | 113 | } |
| 116 | 114 | ||
| 117 | if (!stream2) { | 115 | if (!file2.open(QFile::ReadOnly)) { |
| 118 | LOG_ERROR(Frontend, "Failed to open cache file for reading."); | 116 | LOG_ERROR(Frontend, "Failed to open cache file for reading."); |
| 119 | return generator(); | 117 | return generator(); |
| 120 | } | 118 | } |
| 121 | 119 | ||
| 122 | std::vector<u8> vec(file1.GetSize()); | 120 | std::vector<u8> vec(file1.size()); |
| 123 | file1.ReadBytes(vec.data(), vec.size()); | 121 | if (file1.read(reinterpret_cast<char*>(vec.data()), vec.size()) != |
| 124 | 122 | static_cast<s64>(vec.size())) { | |
| 125 | if (stream2 && !vec.empty()) { | 123 | return generator(); |
| 126 | const std::string out(std::istreambuf_iterator<char>{stream2}, | ||
| 127 | std::istreambuf_iterator<char>{}); | ||
| 128 | return std::make_pair(vec, out); | ||
| 129 | } | 124 | } |
| 130 | 125 | ||
| 131 | return generator(); | 126 | const auto data = file2.readAll(); |
| 127 | return std::make_pair(vec, data.toStdString()); | ||
| 132 | } | 128 | } |
| 133 | 129 | ||
| 134 | void GetMetadataFromControlNCA(const FileSys::PatchManager& patch_manager, const FileSys::NCA& nca, | 130 | void GetMetadataFromControlNCA(const FileSys::PatchManager& patch_manager, const FileSys::NCA& nca, |