From e137ddc89738fa223abedf95eeb338c095ecaf4f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 21 Jul 2021 11:23:57 +0200 Subject: [PATCH] improved HasFileSystemIF api --- src/fsfw/memory/FileSystemArgsIF.h | 14 ++++++++++++++ src/fsfw/memory/HasFileSystemIF.h | 25 ++++++++++++++++--------- 2 files changed, 30 insertions(+), 9 deletions(-) create mode 100644 src/fsfw/memory/FileSystemArgsIF.h diff --git a/src/fsfw/memory/FileSystemArgsIF.h b/src/fsfw/memory/FileSystemArgsIF.h new file mode 100644 index 00000000..4ed34873 --- /dev/null +++ b/src/fsfw/memory/FileSystemArgsIF.h @@ -0,0 +1,14 @@ +#ifndef FSFW_SRC_FSFW_MEMORY_FILESYSTEMARGS_H_ +#define FSFW_SRC_FSFW_MEMORY_FILESYSTEMARGS_H_ + +/** + * Empty base interface which can be implemented by to pass arguments via the HasFileSystemIF. + * Users can then dynamic_cast the base pointer to the require child pointer. + */ +class FileSystemArgsIF { +public: + FileSystemArgsIF(); + virtual~ FileSystemArgsIF(); +}; + +#endif /* FSFW_SRC_FSFW_MEMORY_FILESYSTEMARGS_H_ */ diff --git a/src/fsfw/memory/HasFileSystemIF.h b/src/fsfw/memory/HasFileSystemIF.h index ec941f59..d8d100c0 100644 --- a/src/fsfw/memory/HasFileSystemIF.h +++ b/src/fsfw/memory/HasFileSystemIF.h @@ -1,9 +1,10 @@ #ifndef FSFW_MEMORY_HASFILESYSTEMIF_H_ #define FSFW_MEMORY_HASFILESYSTEMIF_H_ -#include "../returnvalues/HasReturnvaluesIF.h" -#include "../returnvalues/FwClassIds.h" -#include "../ipc/messageQueueDefinitions.h" +#include "FileSystemArgsIF.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/returnvalues/FwClassIds.h" +#include "fsfw/ipc/messageQueueDefinitions.h" #include @@ -59,7 +60,7 @@ public: */ virtual ReturnValue_t appendToFile(const char* repositoryPath, const char* filename, const uint8_t* data, size_t size, - uint16_t packetNumber, void* args = nullptr) = 0; + uint16_t packetNumber, FileSystemArgsIF* args = nullptr) = 0; /** * @brief Generic function to create a new file. @@ -72,7 +73,7 @@ public: */ virtual ReturnValue_t createFile(const char* repositoryPath, const char* filename, const uint8_t* data = nullptr, - size_t size = 0, void* args = nullptr) = 0; + size_t size = 0, FileSystemArgsIF* args = nullptr) = 0; /** * @brief Generic function to delete a file. @@ -81,16 +82,19 @@ public: * @param args Any other arguments which an implementation might require * @return */ - virtual ReturnValue_t deleteFile(const char* repositoryPath, - const char* filename, void* args = nullptr) = 0; + virtual ReturnValue_t removeFile(const char* repositoryPath, + const char* filename, FileSystemArgsIF* args = nullptr) = 0; /** * @brief Generic function to create a directory * @param repositoryPath + * @param Equivalent to the -p flag in Unix systems. If some required parent directories + * do not exist, create them as well * @param args Any other arguments which an implementation might require * @return */ - virtual ReturnValue_t createDirectory(const char* repositoryPath, void* args = nullptr) = 0; + virtual ReturnValue_t createDirectory(const char* repositoryPath, bool createParentDirs, + FileSystemArgsIF* args = nullptr) = 0; /** * @brief Generic function to remove a directory @@ -98,7 +102,10 @@ public: * @param args Any other arguments which an implementation might require */ virtual ReturnValue_t removeDirectory(const char* repositoryPath, - bool deleteRecurively = false, void* args = nullptr) = 0; + bool deleteRecurively = false, FileSystemArgsIF* args = nullptr) = 0; + + virtual ReturnValue_t renameFile(const char* repositoryPath, const char* oldFilename, + const char* newFilename, FileSystemArgsIF* args = nullptr) = 0; };