Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class CCeMiniFileSystem : public CConfigElement
- {
- public:
- bool GetFileInfo(const SoftwareImageSelector_t fileSelector, const uint32_t fileMaxSize, bool& isNewFile,
- uint32_t& baseAddress, uint32_t& currentSize);
- void UpdateCurrentSize(const SoftwareImageSelector_t fileSelector, const uint32_t fileMaxSize,
- const uint32_t additionalBytesWritten);
- void SetItsData(uint8_t* const d, const uint32_t size)
- {
- CConfigElement::SetItsData(d, size);
- fileTable = reinterpret_cast<FileEntry_t*>(data);
- }
- private:
- struct FileEntry_t
- {
- SoftwareImageSelector_t selector;
- uint32_t baseAddressInFlash;
- uint32_t currentSizeInFlash;
- uint32_t MaxSize;
- };
- static const uint32_t MAX_NUMBER_OF_FILES = 7U;
- FileEntry_t* fileTable; //Pointer to a FileEntry_t-Array with 7 Elements
- bool FindFile(const SoftwareImageSelector_t fileSelector, const uint32_t fileMaxSize,
- bool& fileExists, uint32_t& fileEntryIndex) const
- {
- fileExists = false;
- fileEntryIndex = 0U;
- while ((fileExists == false) && (fileEntryIndex < MAX_NUMBER_OF_FILES))
- {
- FileEntry_t& entry = fileTable[fileEntryIndex]; //lint !e1960 5-0-15 careful handling of array implemented
- if (entry.selector.StorageLocation != 2U)
- {
- // no more valid entries available (Storage Location must be 2)
- // break here --> fileEntryIndex contains index for new file
- break;
- }
- if (true == (entry.selector == fileSelector))
- {
- if (entry.MaxSize != fileMaxSize)
- {
- return false; //lint !e904 file already exists return directly
- }
- else
- {
- fileExists = true;
- }
- }
- else
- {
- fileEntryIndex++; // only increment if file not found
- }
- }
- return true;
- }
- };
- class CCeMiniFileSystem : public CConfigElement
- {
- public:
- //...
- void SetItsData(uint8_t* const d, const uint32_t size)
- {
- CConfigElement::SetItsData(d, size);
- fileTable = reinterpret_cast<FileEntry_t(*)[MAX_NUMBER_OF_FILES]>(data);
- }
- private:
- struct FileEntry_t
- {
- //...
- };
- static const uint32_t MAX_NUMBER_OF_FILES = 7U;
- FileEntry_t (* fileTable)[MAX_NUMBER_OF_FILES]; //Pointer to a FileEntry_t-Array with 7 Elements
- bool FindFile(const SoftwareImageSelector_t fileSelector, const uint32_t fileMaxSize,
- bool& fileExists, uint32_t& fileEntryIndex) const
- {
- fileExists = false;
- fileEntryIndex = 0U;
- while ((fileExists == false) && (fileEntryIndex < MAX_NUMBER_OF_FILES))
- {
- FileEntry_t& entry = (*fileTable)[fileEntryIndex];
- //...
- return true;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement