replace ByteBuffer with std::vector

This commit is contained in:
nmzik
2026-09-17 20:03:14 +04:00
parent 5b2935e36c
commit 697b18b366
11 changed files with 25 additions and 233 deletions
+7 -8
View File
@@ -1,7 +1,6 @@
#include "loader/systemContent.h"
#include "common/assert.h"
#include "common/byteBuffer.h"
#include "common/common.h"
#include "common/file.h"
#include "common/logging/log.h"
@@ -121,7 +120,7 @@ void Psf::OpenJson(const std::filesystem::path& file_name) {
}
auto buf = f.ReadWholeBuffer();
if (buf.Size() == 0) {
if (buf.empty()) {
LOGF("invalid json file: %s\n", Common::PathToString(file_name).c_str());
f.Close();
return;
@@ -131,8 +130,8 @@ void Psf::OpenJson(const std::filesystem::path& file_name) {
std::vector<std::string> localized_languages;
std::vector<std::string> localized_titles;
const auto* json_begin = reinterpret_cast<const char*>(buf.GetDataConst());
const auto* json_end = json_begin + buf.Size();
const auto* json_begin = reinterpret_cast<const char*>(buf.data());
const auto* json_end = json_begin + buf.size();
auto param_json = nlohmann::ordered_json::parse(json_begin, json_end, nullptr, false);
if (param_json.is_discarded() || !param_json.is_object()) {
LOGF("invalid json file: %s\n", Common::PathToString(file_name).c_str());
@@ -432,12 +431,12 @@ void PlayGo::OpenChunkDefs(const std::filesystem::path& file_name) {
auto buf = f.ReadWholeBuffer();
f.Close();
if (buf.Size() == 0) {
if (buf.empty()) {
LOGF("invalid file: %s\n", Common::PathToString(file_name).c_str());
return;
}
const std::string_view xml(reinterpret_cast<const char*>(buf.GetDataConst()), buf.Size());
const std::string_view xml(reinterpret_cast<const char*>(buf.data()), buf.size());
uint32_t max_chunk_id = 0;
bool found = false;
@@ -509,9 +508,9 @@ void PlayGo::OpenChunkManifest(const std::filesystem::path& file_name) {
bool chunks[1000] {};
uint32_t max_chunk_id = 0;
bool found = false;
const auto* data = buf.GetDataConst();
const auto* data = buf.data();
for (size_t pos = 0; pos + sizeof(id_field) + sizeof(uint32_t) <= buf.Size(); pos++) {
for (size_t pos = 0; pos + sizeof(id_field) + sizeof(uint32_t) <= buf.size(); pos++) {
if (std::memcmp(data + pos, id_field, sizeof(id_field)) != 0) {
continue;
}