eive-obsw/bsp_q7s/memory/FilesystemHelper.cpp

41 lines
1.3 KiB
C++
Raw Normal View History

2022-01-10 16:18:18 +01:00
#include <fstream>
#include <filesystem>
2022-01-06 18:05:21 +01:00
#include "FilesystemHelper.h"
#include "bsp_q7s/memory/SdCardManager.h"
2022-01-10 16:18:18 +01:00
#include "fsfw/serviceinterface/serviceInterfaceStream.h"
2022-01-06 18:05:21 +01:00
FilesystemHelper::FilesystemHelper() {
}
FilesystemHelper::~FilesystemHelper() {
}
ReturnValue_t FilesystemHelper::checkPath(std::string path) {
2022-01-10 16:18:18 +01:00
SdCardManager* sdcMan = SdCardManager::instance();
2022-01-06 18:05:21 +01:00
if (sdcMan == nullptr) {
sif::warning << "FilesystemHelper::checkPath: Invalid SD card manager" << std::endl;
return RETURN_FAILED;
}
if (path.substr(0, sizeof(SdCardManager::SD_0_MOUNT_POINT))
== std::string(SdCardManager::SD_0_MOUNT_POINT)) {
if (!sdcMan->isSdCardMounted(sd::SLOT_0)) {
sif::warning << "FilesystemHelper::checkPath: SD card 0 not mounted" << std::endl;
return SD_NOT_MOUNTED;
}
} else if (path.substr(0, sizeof(SdCardManager::SD_1_MOUNT_POINT))
== std::string(SdCardManager::SD_1_MOUNT_POINT)) {
if (!sdcMan->isSdCardMounted(sd::SLOT_0)) {
sif::warning << "FilesystemHelper::checkPath: SD card 1 not mounted" << std::endl;
return SD_NOT_MOUNTED;
}
}
return RETURN_OK;
}
ReturnValue_t FilesystemHelper::fileExists(std::string file) {
2022-01-10 16:18:18 +01:00
if (not std::filesystem::exists(file)) {
return FILE_NOT_EXISTS;
}
return RETURN_OK;
2022-01-06 18:05:21 +01:00
}