~aleteoryx/muditaos

ref: b7330da36cb842a913ac82d9d97ab8f5c83708e6 muditaos/module-db/tests/common.cpp -rw-r--r-- 583 bytes
b7330da3 — Dawid Wojtas [MOS-662][MOS-301] Fix E-ink shutdown while restoring data 3 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "common.hpp"
#include <vector>
#include <filesystem>

void RemoveDbFiles(const std::string &dbName)
{
    std::vector<std::string> dbFileExt = {".db", ".db-journal", ".db-wal"};
    for (const auto &ext : dbFileExt) {
        const auto dbPath = (std::filesystem::path{"sys/user"} / std::filesystem::path{dbName + ext});
        if (std::filesystem::exists(dbPath)) {
            std::filesystem::remove(dbPath.c_str());
        }
    }
}