gbe_fork/crash_printer/tests/test_helper.hpp

37 lines
733 B
C++
Raw Normal View History

2024-01-07 21:32:56 +08: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)
{
2024-06-16 01:20:31 +08:00
const std::filesystem::path p_file(std::filesystem::u8path(file));
if (!std::filesystem::exists(p_file)) {
2024-01-07 21:32:56 +08:00
return true;
}
if (std::filesystem::is_directory(p_file)) {
2024-01-07 21:32:56 +08:00
return false;
}
return std::filesystem::remove(p_file);
2024-01-07 21:32:56 +08: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