continued functions to create/delete dir
This commit is contained in:
parent
74fdd90c07
commit
64aadf5e1e
@ -4,6 +4,8 @@
|
||||
#include "fsfw/memory/GenericFileSystemMessage.h"
|
||||
#include "fsfw/ipc/QueueFactory.h"
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
FileSystemHandler::FileSystemHandler(object_id_t fileSystemHandler):
|
||||
SystemObject(fileSystemHandler) {
|
||||
mq = QueueFactory::instance()->createMessageQueue(FS_MAX_QUEUE_SIZE);
|
||||
@ -133,9 +135,40 @@ ReturnValue_t FileSystemHandler::deleteFile(const char *repositoryPath, const ch
|
||||
}
|
||||
|
||||
ReturnValue_t FileSystemHandler::createDirectory(const char *repositoryPath, void *args) {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
std::string fullPath = currentMountPrefix + std::string(repositoryPath);
|
||||
if(std::filesystem::exists(fullPath)) {
|
||||
return DIRECTORY_ALREADY_EXISTS;
|
||||
}
|
||||
if(std::filesystem::create_directory(fullPath)) {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
sif::warning << "Creating directory " << fullPath << " failed" << std::endl;
|
||||
return GENERIC_FILE_ERROR;
|
||||
}
|
||||
|
||||
ReturnValue_t FileSystemHandler::removeDirectory(const char *repositoryPath, void *args) {
|
||||
ReturnValue_t FileSystemHandler::removeDirectory(const char *repositoryPath,
|
||||
bool deleteRecurively, void *args) {
|
||||
std::string fullPath = currentMountPrefix + std::string(repositoryPath);
|
||||
if(not std::filesystem::exists(fullPath)) {
|
||||
return DIRECTORY_DOES_NOT_EXIST;
|
||||
}
|
||||
std::error_code err;
|
||||
if(not deleteRecurively) {
|
||||
if(std::filesystem::remove(fullPath, err)) {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
else {
|
||||
// Check error code. Most probably denied permissions because folder is not empty
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(std::filesystem::remove_all(fullPath, err)) {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
else {
|
||||
// Check error code
|
||||
}
|
||||
}
|
||||
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
@ -47,7 +47,8 @@ private:
|
||||
ReturnValue_t deleteFile(const char* repositoryPath,
|
||||
const char* filename, void* args = nullptr) override;
|
||||
ReturnValue_t createDirectory(const char* repositoryPath, void* args = nullptr) override;
|
||||
ReturnValue_t removeDirectory(const char* repositoryPath, void* args = nullptr) override;
|
||||
ReturnValue_t removeDirectory(const char* repositoryPath, bool deleteRecurively = false,
|
||||
void* args = nullptr) override;
|
||||
};
|
||||
|
||||
|
||||
|
2
fsfw
2
fsfw
@ -1 +1 @@
|
||||
Subproject commit 323577cdc69ee2d863e6e61cebd71a8aa75c6d2b
|
||||
Subproject commit da8a4470734808bed4d872e47c192af694382c41
|
Loading…
Reference in New Issue
Block a user