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-04-28 05:45:11 +08:00
|
|
|
const std::filesystem::u8path p_file(std::filesystem::u8path(file));
|
|
|
|
if (!std::filesystem::exists(p_file)) {
|
2024-01-07 21:32:56 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2024-04-28 05:45:11 +08:00
|
|
|
if (std::filesystem::is_directory(p_file)) {
|
2024-01-07 21:32:56 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2024-04-28 05:45:11 +08:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-04-28 05:45:11 +08:00
|
|
|
#endif // _TEST_CRASH_PRINTER_HELPER_H
|