F´ Flight Software - C/C++ Documentation  devel
A framework for building embedded system applications to NASA flight quality standards.
ValidatedFile.cpp
Go to the documentation of this file.
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 "Utils/Hash/Hash.hpp"
15 
16 namespace Os {
17 
19  ValidatedFile(const char *const fileName) :
20  m_fileName(fileName),
21  m_hashFileName(""),
22  m_hashBuffer()
23  {
24  Utils::Hash::addFileExtension(this->m_fileName, this->m_hashFileName);
25  }
26 
28  validate()
29  {
30  const Os::ValidateFile::Status status =
32  this->m_fileName.toChar(),
33  this->m_hashFileName.toChar(),
34  this->m_hashBuffer
35  );
36  return status;
37  }
38 
41  {
42  const Os::ValidateFile::Status status =
44  this->m_fileName.toChar(),
45  this->m_hashFileName.toChar(),
46  this->m_hashBuffer
47  );
48  return status;
49  }
50 
52  getFileName() const
53  {
54  return this->m_fileName;
55  }
56 
58  getHashFileName() const
59  {
60  return this->m_hashFileName;
61  }
62 
64  getHashBuffer() const
65  {
66  return this->m_hashBuffer;
67  }
68 
69 }
const char * toChar() const
Definition: String.hpp:50
const Fw::StringBase & getFileName() const
const Fw::StringBase & getHashFileName() const
Os::ValidateFile::Status validate()
Os::ValidateFile::Status createHashFile()
const Utils::HashBuffer & getHashBuffer() const
ValidatedFile(const char *const fileName)
Construct a validated file.
A container class for holding a hash buffer.
Definition: HashBuffer.hpp:26
static void addFileExtension(const Fw::StringBase &baseName, Fw::StringBase &extendedName)
Definition: HashCommon.cpp:12
Status createValidation(const char *fileName, const char *hash, Utils::HashBuffer &hashBuffer)
Status validate(const char *fileName, const char *hashFileName, Utils::HashBuffer &hashBuffer)
Validate the contents of a file 'fileName' against its hash.