Refine readFile logic

This commit is contained in:
chiteroman 2024-08-18 00:05:19 +02:00
parent 372be7e799
commit c4959bf520
No known key found for this signature in database

View File

@ -267,27 +267,21 @@ private:
};
static std::vector<uint8_t> readFile(const char *path) {
std::vector<uint8_t> vector;
FILE *file = fopen(path, "rb");
if (file) {
fseek(file, 0, SEEK_END);
long size = ftell(file);
fseek(file, 0, SEEK_SET);
if (!file) return {};
auto size = std::filesystem::file_size(path);
std::vector<uint8_t> vector(size);
vector.resize(size);
fread(vector.data(), 1, size, file);
fclose(file);
} else {
LOGD("Couldn't read %s file!", path);
}
return vector;
}
static void companion(int fd) {
std::vector<uint8_t> dex, json;