| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // ====================================================================== | ||
| 2 | // \title ValidatedFile.cpp | ||
| 3 | // \author bocchino | ||
| 4 | // \brief Os::ValidatedFile implementation | ||
| 5 | // | ||
| 6 | // \copyright | ||
| 7 | // Copyright (C) 2017 California Institute of Technology. | ||
| 8 | // ALL RIGHTS RESERVED. United States Government Sponsorship | ||
| 9 | // acknowledged. | ||
| 10 | // | ||
| 11 | // ====================================================================== | ||
| 12 | |||
| 13 | #include "Os/ValidatedFile.hpp" | ||
| 14 | #include "Fw/Types/Assert.hpp" | ||
| 15 | #include "Utils/Hash/Hash.hpp" | ||
| 16 | |||
| 17 | namespace Os { | ||
| 18 | |||
| 19 | ✗ | ValidatedFile ::ValidatedFile(const char* const fileName) : m_fileName(fileName), m_hashFileName(""), m_hashBuffer() { | |
| 20 | ✗ | const Fw::FormatStatus formatStatus = Utils::Hash::addFileExtension(this->m_fileName, this->m_hashFileName); | |
| 21 | // A truncated hash file name would silently validate against the wrong file | ||
| 22 | ✗ | FW_ASSERT(formatStatus == Fw::FormatStatus::SUCCESS, static_cast<FwAssertArgType>(formatStatus)); | |
| 23 | ✗ | } | |
| 24 | |||
| 25 | ✗ | Os::ValidateFile::Status ValidatedFile ::validate() { | |
| 26 | const Os::ValidateFile::Status status = | ||
| 27 | ✗ | Os::ValidateFile::validate(this->m_fileName.toChar(), this->m_hashFileName.toChar(), this->m_hashBuffer); | |
| 28 | ✗ | return status; | |
| 29 | } | ||
| 30 | |||
| 31 | ✗ | Os::ValidateFile::Status ValidatedFile ::createHashFile() { | |
| 32 | ✗ | const Os::ValidateFile::Status status = Os::ValidateFile::createValidation( | |
| 33 | ✗ | this->m_fileName.toChar(), this->m_hashFileName.toChar(), this->m_hashBuffer); | |
| 34 | ✗ | return status; | |
| 35 | } | ||
| 36 | |||
| 37 | ✗ | Os::ValidateFile::Status ValidatedFile ::createHashFile(const Utils::HashBuffer& hashBuffer) { | |
| 38 | ✗ | this->m_hashBuffer = hashBuffer; | |
| 39 | const Os::ValidateFile::Status status = | ||
| 40 | ✗ | Os::ValidateFile::createValidation(this->m_hashFileName.toChar(), this->m_hashBuffer); | |
| 41 | ✗ | return status; | |
| 42 | } | ||
| 43 | |||
| 44 | ✗ | const Fw::ConstStringBase& ValidatedFile ::getFileName() const { | |
| 45 | ✗ | return this->m_fileName; | |
| 46 | } | ||
| 47 | |||
| 48 | ✗ | const Fw::ConstStringBase& ValidatedFile ::getHashFileName() const { | |
| 49 | ✗ | return this->m_hashFileName; | |
| 50 | } | ||
| 51 | |||
| 52 | ✗ | const Utils::HashBuffer& ValidatedFile ::getHashBuffer() const { | |
| 53 | ✗ | return this->m_hashBuffer; | |
| 54 | } | ||
| 55 | |||
| 56 | } // namespace Os | ||
| 57 |