improved HasFileSystemIF api

This commit is contained in:
Robin Müller 2021-07-21 11:23:57 +02:00
parent d339bf2c9e
commit e137ddc897
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
2 changed files with 30 additions and 9 deletions

View File

@ -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_ */

View File

@ -1,9 +1,10 @@
#ifndef FSFW_MEMORY_HASFILESYSTEMIF_H_ #ifndef FSFW_MEMORY_HASFILESYSTEMIF_H_
#define FSFW_MEMORY_HASFILESYSTEMIF_H_ #define FSFW_MEMORY_HASFILESYSTEMIF_H_
#include "../returnvalues/HasReturnvaluesIF.h" #include "FileSystemArgsIF.h"
#include "../returnvalues/FwClassIds.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h"
#include "../ipc/messageQueueDefinitions.h" #include "fsfw/returnvalues/FwClassIds.h"
#include "fsfw/ipc/messageQueueDefinitions.h"
#include <cstddef> #include <cstddef>
@ -59,7 +60,7 @@ public:
*/ */
virtual ReturnValue_t appendToFile(const char* repositoryPath, virtual ReturnValue_t appendToFile(const char* repositoryPath,
const char* filename, const uint8_t* data, size_t size, 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. * @brief Generic function to create a new file.
@ -72,7 +73,7 @@ public:
*/ */
virtual ReturnValue_t createFile(const char* repositoryPath, virtual ReturnValue_t createFile(const char* repositoryPath,
const char* filename, const uint8_t* data = nullptr, 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. * @brief Generic function to delete a file.
@ -81,16 +82,19 @@ public:
* @param args Any other arguments which an implementation might require * @param args Any other arguments which an implementation might require
* @return * @return
*/ */
virtual ReturnValue_t deleteFile(const char* repositoryPath, virtual ReturnValue_t removeFile(const char* repositoryPath,
const char* filename, void* args = nullptr) = 0; const char* filename, FileSystemArgsIF* args = nullptr) = 0;
/** /**
* @brief Generic function to create a directory * @brief Generic function to create a directory
* @param repositoryPath * @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 * @param args Any other arguments which an implementation might require
* @return * @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 * @brief Generic function to remove a directory
@ -98,7 +102,10 @@ public:
* @param args Any other arguments which an implementation might require * @param args Any other arguments which an implementation might require
*/ */
virtual ReturnValue_t removeDirectory(const char* repositoryPath, 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;
}; };