ValidatedFile.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. #include "Os/ValidatedFile.hpp"
  13. #include "Utils/Hash/Hash.hpp"
  14. namespace Os {
  15. ValidatedFile ::
  16. ValidatedFile(const char *const fileName) :
  17. fileName(fileName),
  18. hashFileName(""),
  19. hashBuffer()
  20. {
  21. Utils::Hash::addFileExtension(this->fileName, this->hashFileName);
  22. }
  23. Os::ValidateFile::Status ValidatedFile ::
  24. validate()
  25. {
  26. const Os::ValidateFile::Status status =
  27. Os::ValidateFile::validate(
  28. this->fileName.toChar(),
  29. this->hashFileName.toChar(),
  30. this->hashBuffer
  31. );
  32. return status;
  33. }
  34. Os::ValidateFile::Status ValidatedFile ::
  35. createHashFile()
  36. {
  37. const Os::ValidateFile::Status status =
  38. Os::ValidateFile::createValidation(
  39. this->fileName.toChar(),
  40. this->hashFileName.toChar(),
  41. this->hashBuffer
  42. );
  43. return status;
  44. }
  45. const Fw::StringBase& ValidatedFile ::
  46. getFileName() const
  47. {
  48. return this->fileName;
  49. }
  50. const Fw::StringBase& ValidatedFile ::
  51. getHashFileName() const
  52. {
  53. return this->hashFileName;
  54. }
  55. const Utils::HashBuffer& ValidatedFile ::
  56. getHashBuffer() const
  57. {
  58. return this->hashBuffer;
  59. }
  60. }