diff --git a/Utilities/File.cpp b/Utilities/File.cpp index da29fba7bd..8fda5c171a 100644 --- a/Utilities/File.cpp +++ b/Utilities/File.cpp @@ -1125,13 +1125,6 @@ bool fs::is_optical_raw_device([[maybe_unused]] const std::string& path) bool fs::get_optical_raw_device(const std::string& path, std::string* raw_device) { - // Skip a useless check to detect an optical raw device if navigating on subfolders (e.g. C:/subfolder_1/subfolder_2/), it means we are on a hdd/ssd. - // A path for an optical drive should include only the drive letter (e.g. E:/) - if (path.find_first_of(":") != path.find_last_not_of(delim)) - { - return false; - } - if (fs::is_optical_raw_device(path)) { if (raw_device) @@ -1143,38 +1136,27 @@ bool fs::get_optical_raw_device(const std::string& path, std::string* raw_device } #ifdef _WIN32 - constexpr u32 BUF_SIZE = 1000; - WCHAR drive_list[BUF_SIZE] = {0}; + // Skip a useless check to detect an optical raw device if navigating on subfolders (e.g. C:\subfolder_1\subfolder_2\), + // it means we are on a HDD/SSD. A path for an optical drive should include only the drive letter (e.g. E:\) + const size_t drive_delim = path.find_first_of(":"); - // GetLogicalDriveStrings() returns a double-null terminated list of null-terminated strings. - // E.g. A:\B:\C:\ - const DWORD copied = GetLogicalDriveStrings(BUF_SIZE, drive_list); - - if (copied == 0 || copied > BUF_SIZE) + if (drive_delim != umax && drive_delim != path.find_last_not_of(delim)) { return false; } - for (const WCHAR* drive = drive_list; drive && *drive; drive += wcslen(drive) + 1) + const std::string drive_letter = path.substr(0, drive_delim + 1); // e.g. "E:" + const std::string drive_path = drive_letter + "\\"; // e.g. "E:\" + + if (GetDriveTypeA(drive_path.c_str()) == DRIVE_CDROM) { - if (GetDriveType(drive) == DRIVE_CDROM) + if (raw_device) { - const std::wstring ws(drive); - const std::string s = std::string(ws.begin(), ws.end() - 1); - - if (path.starts_with(s)) - { - if (raw_device) - { - *raw_device = "\\\\.\\" + s; - } - - return true; - } + *raw_device = "\\\\.\\" + drive_letter; } - } - return false; + return true; + } #endif return false; } diff --git a/rpcs3/Crypto/utils.cpp b/rpcs3/Crypto/utils.cpp index 51ad284c62..7c1d1df309 100644 --- a/rpcs3/Crypto/utils.cpp +++ b/rpcs3/Crypto/utils.cpp @@ -37,6 +37,14 @@ void bytes_to_hex(std::string& hex_str, const unsigned char* data, unsigned int { fmt::throw_exception("Failed to read bytes: %s", std::make_error_code(err).message()); } + + // Padding handling for values ​​< 0x10 (e.g. 0x05 becomes "5" instead of "05") + // If to_chars only writes 1 character, we move to the right and put '0' + if (ptr == &hex_str[i] + 1) + { + hex_str[i + 1] = hex_str[i]; + hex_str[i] = '0'; + } } } diff --git a/rpcs3/Loader/content_validation.cpp b/rpcs3/Loader/content_validation.cpp index 5bf9bbe072..bcd419b094 100644 --- a/rpcs3/Loader/content_validation.cpp +++ b/rpcs3/Loader/content_validation.cpp @@ -32,8 +32,6 @@ content_integrity_status content_validation::check_integrity(content_file_type f case content_file_type::PSN_UPDATE: db_path = rpcs3::utils::get_psn_update_db_path(); break; - default: // Let the following opening attempt fail and log the error message - break; } fs::file db_file(db_path); @@ -63,6 +61,9 @@ content_integrity_status content_validation::check_integrity(content_file_type f return content_integrity_status::ERROR_PARSING_DB; } + // Close the file and work with the data loaded into the "db" document + db_file.close(); + std::shared_ptr db_base = db.GetRoot(); if (!db_base) diff --git a/rpcs3/rpcs3qt/content_integrity.cpp b/rpcs3/rpcs3qt/content_integrity.cpp index 5b89c6ff37..13768ef1dd 100644 --- a/rpcs3/rpcs3qt/content_integrity.cpp +++ b/rpcs3/rpcs3qt/content_integrity.cpp @@ -33,8 +33,6 @@ content_integrity::content_integrity(QWidget* parent, content_file_type file_typ m_url = rpcs3::utils::get_psn_update_db_download_url(); m_data_prefix = "psn_update"; break; - default: // Let the further download attempt fail and log the error message - break; } m_downloader = new downloader(parent); diff --git a/rpcs3/rpcs3qt/game_list_context_menu.cpp b/rpcs3/rpcs3qt/game_list_context_menu.cpp index 53a8cd03af..3e1d02df67 100644 --- a/rpcs3/rpcs3qt/game_list_context_menu.cpp +++ b/rpcs3/rpcs3qt/game_list_context_menu.cpp @@ -636,7 +636,7 @@ void game_list_context_menu::show_single_selection_context_menu(const game_info& } else // Check HDD game integrity { - QAction* check_psn_content = check_integrity_menu->addAction(tr("&Check Game Integrity")); + QAction* check_psn_content = check_integrity_menu->addAction(tr("&Check Game PKG Integrity")); // If the integrity DB exists if (content_validation::check_integrity(content_file_type::PSN_CONTENT, "") != content_integrity_status::ERROR_OPENING_DB) @@ -652,7 +652,7 @@ void game_list_context_menu::show_single_selection_context_menu(const game_info& } } - QAction* check_psn_dlc = check_integrity_menu->addAction(tr("&Check DLC Integrity")); + QAction* check_psn_dlc = check_integrity_menu->addAction(tr("&Check DLC PKG Integrity")); // If the integrity DB exists if (content_validation::check_integrity(content_file_type::PSN_DLC, "") != content_integrity_status::ERROR_OPENING_DB) @@ -667,7 +667,7 @@ void game_list_context_menu::show_single_selection_context_menu(const game_info& check_psn_dlc->setEnabled(false); } - QAction* check_psn_update = check_integrity_menu->addAction(tr("&Check Update Integrity")); + QAction* check_psn_update = check_integrity_menu->addAction(tr("&Check Update PKG Integrity")); // If the integrity DB exists if (content_validation::check_integrity(content_file_type::PSN_UPDATE, "") != content_integrity_status::ERROR_OPENING_DB)