Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.67 KB | None | 0 0
  1. class CCeMiniFileSystem : public CConfigElement
  2. {
  3. public:
  4.  
  5. bool GetFileInfo(const SoftwareImageSelector_t fileSelector, const uint32_t fileMaxSize, bool& isNewFile,
  6. uint32_t& baseAddress, uint32_t& currentSize);
  7.  
  8. void UpdateCurrentSize(const SoftwareImageSelector_t fileSelector, const uint32_t fileMaxSize,
  9. const uint32_t additionalBytesWritten);
  10.  
  11. void SetItsData(uint8_t* const d, const uint32_t size)
  12. {
  13. CConfigElement::SetItsData(d, size);
  14. fileTable = reinterpret_cast<FileEntry_t*>(data);
  15. }
  16.  
  17. private:
  18.  
  19. struct FileEntry_t
  20. {
  21. SoftwareImageSelector_t selector;
  22. uint32_t baseAddressInFlash;
  23. uint32_t currentSizeInFlash;
  24. uint32_t MaxSize;
  25. };
  26.  
  27. static const uint32_t MAX_NUMBER_OF_FILES = 7U;
  28. FileEntry_t* fileTable; //Pointer to a FileEntry_t-Array with 7 Elements
  29.  
  30. bool FindFile(const SoftwareImageSelector_t fileSelector, const uint32_t fileMaxSize,
  31. bool& fileExists, uint32_t& fileEntryIndex) const
  32. {
  33. fileExists = false;
  34. fileEntryIndex = 0U;
  35. while ((fileExists == false) && (fileEntryIndex < MAX_NUMBER_OF_FILES))
  36. {
  37. FileEntry_t& entry = fileTable[fileEntryIndex]; //lint !e1960 5-0-15 careful handling of array implemented
  38.  
  39. if (entry.selector.StorageLocation != 2U)
  40. {
  41. // no more valid entries available (Storage Location must be 2)
  42. // break here --> fileEntryIndex contains index for new file
  43. break;
  44. }
  45. if (true == (entry.selector == fileSelector))
  46. {
  47. if (entry.MaxSize != fileMaxSize)
  48. {
  49. return false; //lint !e904 file already exists return directly
  50. }
  51. else
  52. {
  53. fileExists = true;
  54. }
  55. }
  56. else
  57. {
  58. fileEntryIndex++; // only increment if file not found
  59. }
  60. }
  61.  
  62. return true;
  63. }
  64.  
  65. };
  66.  
  67. class CCeMiniFileSystem : public CConfigElement
  68. {
  69. public:
  70. //...
  71. void SetItsData(uint8_t* const d, const uint32_t size)
  72. {
  73. CConfigElement::SetItsData(d, size);
  74. fileTable = reinterpret_cast<FileEntry_t(*)[MAX_NUMBER_OF_FILES]>(data);
  75. }
  76.  
  77. private:
  78.  
  79. struct FileEntry_t
  80. {
  81. //...
  82. };
  83.  
  84. static const uint32_t MAX_NUMBER_OF_FILES = 7U;
  85. FileEntry_t (* fileTable)[MAX_NUMBER_OF_FILES]; //Pointer to a FileEntry_t-Array with 7 Elements
  86.  
  87. bool FindFile(const SoftwareImageSelector_t fileSelector, const uint32_t fileMaxSize,
  88. bool& fileExists, uint32_t& fileEntryIndex) const
  89. {
  90. fileExists = false;
  91. fileEntryIndex = 0U;
  92. while ((fileExists == false) && (fileEntryIndex < MAX_NUMBER_OF_FILES))
  93. {
  94. FileEntry_t& entry = (*fileTable)[fileEntryIndex];
  95. //...
  96. return true;
  97. }
  98.  
  99. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement