continued functions to create/delete dir
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user