Filesystem and CFDP updates

This commit is contained in:
2024-05-24 14:29:42 +02:00
parent a1b6e2ff89
commit 20819dd99a
98 changed files with 919 additions and 863 deletions

View File

@ -20,7 +20,7 @@
class FilesystemMock : public HasFileSystemIF {
public:
struct FileWriteInfo {
FileWriteInfo(std::string filename, size_t offset, const uint8_t *data, size_t len)
FileWriteInfo(std::string filename, size_t offset, const uint8_t* data, size_t len)
: filename(std::move(filename)), offset(offset) {
this->data.insert(this->data.end(), data, data + len);
}
@ -54,24 +54,34 @@ class FilesystemMock : public HasFileSystemIF {
};
std::queue<RenameInfo> renameQueue;
std::string truncateCalledOnFile;
ReturnValue_t feedFile(const std::string &filename, std::ifstream &file);
ReturnValue_t feedFile(const std::string& filename, std::ifstream& file);
ReturnValue_t getBaseFilename(FilesystemParams params, char *nameBuf, size_t maxLen,
size_t &baseNameLen) override;
ReturnValue_t getBaseFilename(const char* path, char* nameBuf, size_t maxLen,
size_t& baseNameLen) override;
bool isDirectory(const char *path) override;
bool fileExists(FilesystemParams params) override;
ReturnValue_t truncateFile(FilesystemParams params) override;
bool getFileSize(FilesystemParams params, size_t &fileSize) override;
ReturnValue_t isDirectory(const char* path, bool& isDirectory) override;
ReturnValue_t writeToFile(FileOpParams params, const uint8_t *data) override;
ReturnValue_t readFromFile(FileOpParams params, uint8_t **buffer, size_t &readSize,
size_t maxSize) override;
ReturnValue_t createFile(FilesystemParams params, const uint8_t *data, size_t size) override;
ReturnValue_t removeFile(const char *path, FileSystemArgsIF *args) override;
ReturnValue_t createDirectory(FilesystemParams params, bool createParentDirs) override;
ReturnValue_t removeDirectory(FilesystemParams params, bool deleteRecurively) override;
ReturnValue_t rename(const char *oldPath, const char *newPath, FileSystemArgsIF *args) override;
bool fileExists(const char* path, FileSystemArgsIF* args) override;
ReturnValue_t truncateFile(const char* path, FileSystemArgsIF* args) override;
ReturnValue_t getFileSize(const char* path, uint64_t& fileSize, FileSystemArgsIF* args) override;
ReturnValue_t writeToFile(const char* path, size_t offset, const uint8_t* data,
size_t size) override;
ReturnValue_t readFromFile(const char* path, size_t offset, size_t size, uint8_t* buffer,
size_t& readSize, size_t maxSize) override;
ReturnValue_t createFile(const char* path, const uint8_t* data, size_t size) override;
ReturnValue_t removeFile(const char* path, FileSystemArgsIF* args) override;
ReturnValue_t createDirectory(const char* path, bool createParentDirs,
FileSystemArgsIF* args) override;
ReturnValue_t removeDirectory(const char* path, bool deleteRecurively,
FileSystemArgsIF* args) override;
ReturnValue_t rename(const char* oldPath, const char* newPath, FileSystemArgsIF* args) override;
void reset();
@ -80,7 +90,7 @@ class FilesystemMock : public HasFileSystemIF {
using HasFileSystemIF::readFromFile;
private:
void createOrAddToFile(FileOpParams params, const uint8_t *data);
void createOrAddToFile(const char* path, size_t offset, const uint8_t* data, size_t dataSize);
};
#endif // FSFW_MOCKS_FILESYSTEMMOCK_H