diff --git a/mission/tmtc/TmStore.cpp b/mission/tmtc/TmStore.cpp index 960a2054..a2aec09c 100644 --- a/mission/tmtc/TmStore.cpp +++ b/mission/tmtc/TmStore.cpp @@ -3,8 +3,8 @@ #include #include -#include #include +#include using namespace returnvalue; @@ -55,7 +55,7 @@ ReturnValue_t TmStore::passPacket(PusTmReader& reader) { ReturnValue_t TmStore::storePacket(PusTmReader& reader) { using namespace std::filesystem; std::string currentPrefix = sdcMan.getCurrentMountPrefix(); - path baseDir = currentPrefix / baseName; + path baseDir = path(currentPrefix) / baseName; // It is assumed here that the filesystem is usable. if (not exists(baseDir)) { create_directory(baseDir); @@ -69,14 +69,14 @@ ReturnValue_t TmStore::storePacket(PusTmReader& reader) { } auto pathStr = file.path().string(); Clock::TimeOfDay_t tod; - if(pathStr.find(baseName) == std::string::npos) { - continue; + if (pathStr.find(baseName) == std::string::npos) { + continue; } float seconds = 0.0; char* prefix = nullptr; - int count = sscanf(pathStr.c_str(), "%s_%4" SCNu32 "-%2" SCNu32 "-%2" - SCNu32 "T%2" SCNu32 ":%2" SCNu32 ":%fZ", prefix, &tod.year, &tod.month, &tod.day, - &tod.hour, &tod.minute, &seconds); + int count = sscanf(pathStr.c_str(), + "%s_%4" SCNu32 "-%2" SCNu32 "-%2" SCNu32 "T%2" SCNu32 ":%2" SCNu32 ":%fZ", + prefix, &tod.year, &tod.month, &tod.day, &tod.hour, &tod.minute, &seconds); tod.second = std::floor(seconds); static_cast(count); } diff --git a/unittest/CMakeLists.txt b/unittest/CMakeLists.txt index 1786b71e..977b794f 100644 --- a/unittest/CMakeLists.txt +++ b/unittest/CMakeLists.txt @@ -4,5 +4,6 @@ add_subdirectory(mocks) target_sources(${UNITTEST_NAME} PRIVATE main.cpp testEnvironment.cpp + testStampInFilename.cpp printChar.cpp ) \ No newline at end of file diff --git a/unittest/testStampInFilename.cpp b/unittest/testStampInFilename.cpp new file mode 100644 index 00000000..33a0f5a6 --- /dev/null +++ b/unittest/testStampInFilename.cpp @@ -0,0 +1,18 @@ + +#include +#include + +#include "fsfw/timemanager/Clock.h" + +TEST_CASE("Stamp in Filename", "[Stamp In Filename]") { + Clock::TimeOfDay_t tod; + std::string baseName = "verif"; + std::string pathStr = "verif_2022-05-25T16:55:23Z.bin"; + float seconds = 0.0; + char* prefix = nullptr; + int count = + sscanf(pathStr.c_str(), + "%s_%4" SCNu32 "-%2" SCNu32 "-%2" SCNu32 "T%2" SCNu32 ":%2" SCNu32 ":%2" SCNu32 "Z", + prefix, &tod.year, &tod.month, &tod.day, &tod.hour, &tod.minute, &tod.second); + static_cast(count); +}