[ox/fs] Add separate case for write in FileLocation model

This commit is contained in:
Gary Talent 2022-07-21 02:17:11 -05:00
parent fd89a9abb0
commit 6b9d9c50c7

View File

@ -145,11 +145,15 @@ constexpr Error model(T *io, CommonPtrWith<FileAddress> auto *fa) noexcept {
int8_t type = 0;
oxReturnError(io->field("type", &type));
oxReturnError(io->field("data", UnionView(&fa->m_data, 0)));
} else {
} else if constexpr(ox_strcmp(T::opType(), OpType::Read) == 0) {
auto type = static_cast<int8_t>(fa->m_type);
oxReturnError(io->field("type", &type));
fa->m_type = static_cast<FileAddressType>(type);
oxReturnError(io->field("data", UnionView(&fa->m_data, static_cast<int>(fa->m_type))));
} else if constexpr(ox_strcmp(T::opType(), OpType::Write) == 0) {
auto type = static_cast<int8_t>(fa->m_type);
oxReturnError(io->field("type", &type));
oxReturnError(io->field("data", UnionView(&fa->m_data, static_cast<int>(fa->m_type))));
}
return OxError(0);
}