gbe_fork/crash_printer/tests/test_helper.hpp
otavepto e2980d100e * use std::filesystem::u8path to support utf-8
* don't sanitize paths in settings_parser since it removes the colon ':', preventing the usage of absolute paths on Windows like 'C:\aa\bb'
2024-04-28 19:44:56 +03:00

37 lines
735 B
C++

#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)) {
return true;
}
if (std::filesystem::is_directory(p_file)) {
return false;
}
return std::filesystem::remove(p_file);
}
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