host filesystem continued

This commit is contained in:
2022-08-17 11:39:15 +02:00
parent 2e52d7a31d
commit 23f514039a
5 changed files with 44 additions and 19 deletions

View File

@ -19,13 +19,9 @@ struct FilesystemParams {
struct FileOpParams {
FileOpParams(const char* path, size_t size) : fsParams(path), size(size) {}
[[nodiscard]] const char* path() const {
return fsParams.path;
}
[[nodiscard]] const char* path() const { return fsParams.path; }
[[nodiscard]] FileSystemArgsIF* args() const {
return fsParams.args;
}
[[nodiscard]] FileSystemArgsIF* args() const { return fsParams.args; }
FilesystemParams fsParams;
size_t size;

View File

@ -134,7 +134,8 @@ ReturnValue_t PusDistributor::initialize() {
return ObjectManagerIF::CHILD_INIT_FAILED;
}
if (verifyChannel == nullptr) {
verifyChannel = ObjectManager::instance()->get<VerificationReporterIF>(objects::VERIFICATION_REPORTER);
verifyChannel =
ObjectManager::instance()->get<VerificationReporterIF>(objects::VERIFICATION_REPORTER);
if (verifyChannel == nullptr) {
return ObjectManagerIF::CHILD_INIT_FAILED;
}

View File

@ -40,14 +40,14 @@ ReturnValue_t HostFilesystem::readFromFile(FileOpParams params, uint8_t **buffer
if (file.fail()) {
return HasFileSystemIF::GENERIC_FILE_ERROR;
}
auto readLen = static_cast<unsigned int>(params.offset);
file.seekg(readLen);
if (readSize + params.size > maxSize) {
auto sizeToRead = static_cast<unsigned int>(params.size);
file.seekg(static_cast<unsigned int>(params.offset));
if (readSize + sizeToRead > maxSize) {
return SerializeIF::BUFFER_TOO_SHORT;
}
file.read(reinterpret_cast<char *>(*buffer), readLen);
readSize += readLen;
*buffer += readLen;
file.read(reinterpret_cast<char *>(*buffer), sizeToRead);
readSize += sizeToRead;
*buffer += sizeToRead;
return HasReturnvaluesIF::RETURN_OK;
}