gbe_fork/crash_printer/tests/test_helper.hpp

37 lines
735 B
C++
Raw Normal View History

2024-01-07 15:32:56 +02:00
#ifndef _TEST_CRASH_PRINTER_HELPER_H
#define _TEST_CRASH_PRINTER_HELPER_H
#include <filesystem>
#include <string>
static inline bool remove_file(const std::string &file)
{
const std::filesystem::u8path p_file(std::filesystem::u8path(file));
if (!std::filesystem::exists(p_file)) {
2024-01-07 15:32:56 +02:00
return true;
}
if (std::filesystem::is_directory(p_file)) {
2024-01-07 15:32:56 +02:00
return false;
}
return std::filesystem::remove(p_file);
2024-01-07 15:32:56 +02:00
}
static inline bool remove_file(const std::wstring &file)
{
if (!std::filesystem::exists(file)) {
return true;
}
if (std::filesystem::is_directory(file)) {
return false;
}
return std::filesystem::remove(file);
}
#endif // _TEST_CRASH_PRINTER_HELPER_H